Re: Using EUGrid in IDE
- Posted by Jonas Temple <jtemple at yhti.net> Jul 30, 2004
- 698 views
Craig Welch wrote: > > > I'm sure the answer to this question, when revealed to me by the august > participants > in this forum, will be so blindingly obvious that I will thwack myself on the > forehead > with the palm of my hand, and utter in a soulful way 'Duh'! > > Maybe it's just too late at night. But here goes: > > I want to build a grid. I've done a little fooling around with the samples, > and made > a grid like the one I want, outside IDE. > > Now I want to add this grid to an existing IDE project. I open up the project, > and > click 'grid', click again, and there it is. A grid exists. Now, just where in > the IDE > environment do I enter the code that will give the grid the necessary > attributes? Code > such as 'EGW-ADDColumn'? > > If this was a button or field, I could trap user actions by using IDE to setup > actions > for 'onClick', etc. How in IDE do I trap user actions such as EGW_CELLCHANGE? > > Thanks all, > > -- > Craig > Craig, To add a column to the grid just select a control and drop it into the (i.e. a static control). This will add the necessary EGW_AddColumn to the grid. As far as EuGrid event handling is concerned, all events are sent to the _onEvent routine for the grid control. In the event you'll have to disect the parameters to determine what the event was. Here's an EuGrid event handling routine from one of my programs:
procedure ColMapEG_onEvent (integer self, integer event, sequence params)--params is ( int iMsg, atom wParm, atom lParm ) atom msg, wParam, lParam, row_count sequence check_libs, msgs object row_data -- Extract message and params msg = params[1] wParam = params[2] lParam = params[3] -- On cell change save the data for the cell being exited if msg = EGW_CELLCHANGE then void = EGW_SaveCellData(ColMapEG, EGW_GetCurrentCell(ColMapEG)) -- When the row changes elsif msg = EGW_ROWCHANGE then row_data = EGW_GetDataRow(ColMapEG, wParam) -- The user must select either a column name or type a default value -- for each record if not length(row_data[CSVColumn]) and not length(row_data[DftValue]) then void = message_box("You must select either a column name or supply a default " & "value for each column!", "Missing Column Data", MB_OK) -- Ensure the cell in error is displayed void = EGW_ScrollToCell(ColMapEG, wParam, CSVColumn) -- Set the focus to the library grid setFocus(ColMapEG) -- This instructs the grid control to not perform any more processing -- for this event returnValue(True) return end if -- The user must not select a column name and type a default value -- for each record if length(row_data[CSVColumn]) and length(row_data[DftValue]) then void = message_box("You can only select either a column name or supply a default " & "value for each column!", "Column Data Specified Twice", MB_OK) -- Ensure the cell in error is displayed void = EGW_ScrollToCell(ColMapEG, wParam, CSVColumn) -- Set the focus to the library grid setFocus(ColMapEG) -- This instructs the grid control to not perform any more processing -- for this event returnValue(True) return end if -- If the user specified a default value then ensure the data is consistent -- with the column type if length(row_data[DftValue]) then if find(row_data[ColType],sql_numeric_types) then rtn_obj = value(row_data[DftValue]) if rtn_obj[1] != GET_SUCCESS then void = message_box("Default value is invalid for column Type", "Invalid Default Value", MB_OK) -- Ensure the cell in error is displayed void = EGW_ScrollToCell(ColMapEG, wParam, DftValue) -- Set the focus to the library grid setFocus(ColMapEG) -- This instructs the grid control to not perform any more processing -- for this event returnValue(True) return end if end if end if end if end procedure setHandler( ColMapEG, w32HEvent, routine_id("ColMapEG_onEvent"))
Make sure you also take a look at the documentation that comes with EuGrid, it will explain this in more detail. Jonas