I use the WebDataGrid.InitializeDefaultEditors.
In my event handler I have written the following code:
void OnInitializeDefaultEditors(object sender, DefaultEditorsEventArgs e){ e.NumericEditor.Buttons.SpinOnArrowKeys = false; e.NumericEditor.ClientEvents.KeyDown = "j_onNumericEditorKeyDown";}
The SpinOnArrowKeys is succesfully disabled, but the KeyDown event is not fired.
Hi,
Editor does not know about grid, so, you can not access grid or its cell within client events of editor. However, you may process start/end edit mode of grid, create a global variable which contains reference to editing cell and access that cell from that global variable. Below is example:
<script type="text/javascript"> var editCell = null; function enteredEditMode(grid, args) { editCell = args.getCell(); } function exitedEditMode(grid, args) { editCell = null; } function j_onNumericEditorKeyDown(editor, args) { if(editCell) _bug4('key:'+args.get_browserEvent().keyCode+':'+':'+editCell.get_value()); }</script><ig:WebDataGrid ID="WebDataGrid1" runat="server" Height="350px" Width="400px"> <Behaviors> <ig:EditingCore> <Behaviors> <ig:CellEditing> <CellEditingClientEvents EnteredEditMode="enteredEditMode" ExitedEditMode="exitedEditMode" /> ...
Hi Viktor,
Thanks for your answer. I registered the event in my page constructor. Once I moved the event registration to the page load event it works.
I have a follow-up question. I hope you can help me. How do I get a reference to the grid cell which is being edited, when the keydown event of the numeric editor fires?
Roland
I added your codes to a sample page with grid, but I could not reproduce that issue. I implemented KeyDown by following, and event was raised for all keys including up/down arrows (output lines were "key:38", "key:40").
<script type="text/javascript"> function j_onNumericEditorKeyDown(editor, args) { _bug4('key:'+args.get_browserEvent().keyCode); } </script>
I tested IE7 and Firefox.It is possible that something else interacts with key events. I suggest you to test a temporary page which has only grid and that event handler.