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 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
After several attempts, I am back to attempting to use the OnSelectionChanged attribute in the EditorControl.
In code behind, i can get the new value thus...
protected
void MyDataGrid_UserChanged( object sender, EventArgs
e)
{
// get it...
int newId = Int32.Parse(((Infragistics.Web.UI.ListControls.WebDropDown)sender).SelectedValue);
}
What I need is a way to get at the current row information to my server-side code.
is there a way to get the Row, or an ID from another column into a HiddenField using javascript?
what client side event can/should I use?
I am not using the WDG as a data-editor... rather a simple data entry UI -
Here is my data:
Resource Shift User
Resource and Shift are READ ONLY
User is a drop-down listbox - that defaults to "unassigned"
When someone selects a 'User' using the drop-down, I need to save that in the database (code behind)
requiring a form submit, or a save on exit of page does not work for my feature.
I also am having trouble reliably getting the changes on my form (based on your sample)
Granted, I have a master page, and my WDG is on a User Control - that is added to the page at runtime.
Hi Mike,
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();}
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!!!!