Re: EuGrid: How to use onGotFocus for a "cell"?
- Posted by Jonas Temple <jtemple at yhti.net> Feb 21, 2007
- 481 views
Rad wrote: > I have one more question. > > How can I trap w32HChange and w32HLostFocus for EGW_EDIT cells? I use the following:
if msg=EGW_KEYCHAR then -- Get the field type information for this column col_index = find(cur_cell[2], fe_gridcolumns) if col_index then -- Don't allow a numeric field to go over it's maximum size if fe_columns[col_index][fe_precision] then rtn_value = validNumberKey(cur_cell[1], cur_cell[2], wParam) else rtn_value = 0 end if -- Enable the save button for valid keys if rtn_value = 0 then setEnable(FESavePB, True) end if -- This should never happen, but just in case, don't allow the key else returnValue(1) end if
The validNumber routine gets the value of the edit cell. This is accomplished with a new routine I added to eugrid (right before EGW_GetCurrentCell):
--*------------------------------------------------------* -- EGW_GetCurrentCellValue - Get the value in the cell's edit control --*------------------------------------------------------* function EGW_GetCurrentCellValue ( integer grid, sequence cell ) integer control, col, datacol, index -- Get index for column id in cell col = EGW_GetColumnIndex( grid, cell[COL_ID]) -- If a valid cell then save changes if length(GridData[grid])>0 and cell[ROW]>0 and col>0 then -- Get underlying data column for grid column datacol = GridCol[grid][col][EGW_COL_DATACOL] -- Get edit control for column control = EGW_GetEditControlForCell ( grid, cell ) if datacol > 0 and control > 0 then return EGW_GetText( GridControl[grid][control][HWND] ) end if end if return 0 end function
The above routine gets the cell's value BEFORE it's saved to the underlying dataset. My validNumberKey routine returns 0 if the key should be allowed. > Like EGW_SaveCellData(), can there be EGW_LoadCellData() in future verion of > EuGrid > for loading individual cell data instead of entire grid? You can do this via the EuGrid routine: boolean = EGW_SetDataCellValue ( integer id, atom row, atom datacol, object value ) Jonas Temple http://www.innovativesys.net