I have successfully added a DropDown Provider in my WebDataGrid, and it correctly displays the selections available to the user.
I am trying to determine how to get the OnSelectionChanged event back to my server-side code...
What are the arguments to the OnSelectionChanged method? I can't find them anywhere...
Thanks!
Hi,
The OnSelectionChanged server event will not be raised for the DropDown Provider. None of the editor server events will be raised in fact, because they are providers and are embedded in the grid, they don't exist on the page itself, hence their events will not be raised. The client events for the editor providers will be raised at the correct times you can handle these to see the selection changed. If you want to see the actual value of the cell and what it was changed to on the server you can handle the RowUpdating or RowUpdated event.
Thanks,Olga
Being new to editing within WebDataGrid - I tried to get the OnSelectionChanged event back to the server side... and was successful...
<EditorProviders>
<ig:DropDownProvider ID="foo">
<EditorControl
...lots of attributes...
OnSelectionChanged="MyGrid_Operator_SelectionChanged" >
<AutoPostBackFlags SelectionChanged="On" />
<DropDownItemBinding blah blah blah />
</EditorControl>
In the debugger, I do get called server-side when dropdown selection is changed...
But, now I need to determine how to get at:
- which row was changed, and
- which item was selected in hte drop down.
But - I'd rather accomplish this using what you suggest - can you provide a simple example of how to handle RowUpdated event - how to access the row, and its new data -
I'm binding to my own business objects so would like to handle row updates when they occur
Hi Mike,
I am attaching the sample which has the RowUpdating and RowUpdated event handled, with comments in the event handlers (please note that in the sample i am using a DropDownProvider, but for these events it really wouldn't matter if I had the editor provider there or not) These events will be raised once you make changed to one or more cells in a row, and then click on another row thus making the edited row inactive.
Thanks,olga
I like how much cleaner the code to handle the changes is... but -
Is there anyway to get the event to the server whn it happens, and not upon next click.
If I edit a cell, then select another row - I get WebDataGrid1_RowUpdating to fire.
But, If I edit a cell, then click a link to another page - I never record the change to the Row...
Seems like a big issue - how does one guard against lost edits using RowUpdating?
Thanks for your help so far!!!!
WDG works like an Access database in this case, until the row becomes inactive in the grid the data is not committed. If you except your users to perform these type of actions (edit the row and before leaving it, click on a link to go to another page), you can write a bit of code to force the commitment of the edit. You can do this on the form submitting lets say or on a page redirect, by calling the commit() java script function of the editingCore behavior or you can even listen on for the grid's ExitedEditMode client event, check that you are getting this event for the last cell and if so force the commitment of the edit, which is what the code below is showing how to do.
In your ASPX, handler the ExitedEditMode client event:<ig:CellEditing> <ColumnSettings> <ig:EditingColumnSetting ColumnKey="Column 6" EditorID="WebDataGrid1_DropDownProvider1" /> </ColumnSettings> <CellEditingClientEvents ExitedEditMode="exitedEditMode" /></ig:CellEditing>
Then your js script handler for the event would look like this (please not calling the commit will not only force the server commit of updates, but if the user added a new row or deleted a row those changes will be commited by calling commit as well):
function
exitedEditMode(grid, args){ var cell = args.getCell(); var column = cell.get_column(); var editBehavior = grid.get_behaviors().get_editingCore();
editBehavior.commit();}
Hi Olga,
The commit is such a valuable method, but it's important that the users be told that you have to handle the server side rowupdated event (even without any code there) just to get the commit method to work. I can't tell you how many hours we spent on this. Mike D. just clarified that for me today.
Thanks, Ed