Re: EuGrid: How to use onGotFocus for a "cell"?
- Posted by Rad <radhx at rediffmail.com> Feb 21, 2007
- 497 views
Hi Phil, Thanks for the code. I could successfully incorporate it in my system as follows:
procedure EuGrid802_onEvent (integer self, integer event, sequence params)--params is ( int iMsg, atom wParm, atom lParm ) atom rowkey, col_id object datavalue sequence currCell currCell = EGW_GetCurrentCell(self) rowkey = iff(currCell[1] > 0, currCell[1], 1) col_id = iff(currCell[2] > 0, currCell[2], 1) if params[1] = EGW_CELLEDIT then if find(col_id, {3, 4}) then if not find(params[2], valAmtChars) then returnValue(w32True) -- Invalid Amt Char end if end if elsif params[1] = WM_COMMAND then if col_id = 2 then -- Check combo for changes if W32_hi_word(params[2]) = CBN_CLOSEUP then datavalue = GetComboText(params[3]) LatestACH[rowkey][11] = getMasCodeDesc(4, w32TextToNumber(datavalue), 1) -- set new formula desc setText(EditText806, LatestACH[rowkey][10]) setText(EditText808, LatestACH[rowkey][11]) elsif W32_hi_word(params[2]) = CBN_SETFOCUS then datavalue = EGW_GetDataCellValue(self, rowkey, ACHDataCols[col_id]) LatestACH[rowkey][11] = getMasCodeDesc(4, w32TextToNumber(datavalue), 1) -- set new formula desc setText(EditText806, LatestACH[rowkey][10]) setText(EditText808, LatestACH[rowkey][11]) end if end if elsif params[1] = WM_SETFOCUS then if not (col_id = 2) then setText(EditText806, LatestACH[rowkey][10]) setText(EditText808, LatestACH[rowkey][11]) end if elsif params[1] = EGW_CELLCHANGE then if col_id = 2 then -- Formula void = EGW_SaveCellData(self, {rowkey, col_id}) datavalue = EGW_GetDataRow(self, rowkey) datavalue = datavalue[ACHDataCols[col_id]] if not find(datavalue, ACHFormulae) then setText(EditText808, "Invalid Formula Code: " & datavalue) returnValue(w32True) -- Invalid Formula Code end if end if end if setText(StatusBar776, "Row, Col: "&sprintf("%d, %d", {rowkey, col_id})) end procedure setHandler( EuGrid802, w32HEvent, routine_id("EuGrid802_onEvent"))
I have one more question. How can I trap w32HChange and w32HLostFocus for EGW_EDIT cells? For each key-stroke used in EGW_EDIT cell, I want to invoke an existing function (Amount Handler) which will format the entered value. Then I will set it back to EGW_EDIT cell. (I am using this function for win32lib EditText controls for formatting amount fields) I could not apply this function using EGW_CELLEDIT event but I could format the EGW_EDIT cell on EGW_CELLCHANGE event by - 1] Save and extract EGW_EDIT value using SaveCellData() and GetDataCellValue(). 2] move the entered EGW_EDIT value to an EditText control. 2] invoke the amount handler function by means of setHandler() for EditText. 3] update the underlying dataset column with formatted value. 4] reload the grid. Like EGW_SaveCellData(), can there be EGW_LoadCellData() in future verion of EuGrid for loading individual cell data instead of entire grid? Regards, Rad.