Hi,
I am using a WebDataGrid with the RowAdding behavior and the default RowAdding row at the top of the grid. My users want the row add to be sent to the server if any of the add row cells have been populated and if the user then clicks on a different row. Right now, the row add is only sent to the user if the user presses the enter key or else presses the tab key past the end of the row.
I am trying to test all of these conditions, but I'm having trouble first identifying the add row as follows:
sender.get_behaviors().get_editingCore().get_behaviors().getBehaviorByName("RowAdding").get_row();
getBehaviorByName("RowAdding") appears to be what is failing. I have tried get_rowAdding() as well. What is the correct method to get the Add row?
Once I get that, my plan is see if any cells in the add row are populated. Next, I would to compare the Active row and see if it is the same row as the Add Row. If not, then I would use the EditingCore.commit() method to send the added row to the server. Does that make sense?
Hi rbailey003,
Have you tried the following?sender.get_behaviors().get_editingCore().get_behaviors().get_rowAdding().get_row ();
regards,David Young
I had tried that, and it didn't work, but it turns out it was because I put the code in the RowAdding_Initialize event because I wanted to get a handle on the Add Row up front just once. I moved the code to the CellActivated event, and it worked.
Now I'm trying to distinguish whether the current activated row is the add row or not. I tried the index property, but the Filtering row has the same index as the Adding row, so the index won't work. I have tried setting the Tag property of the Adding row on the server, and then I tried checking whether the current row's tag property is the same:
Server code:
dgAdHocPayment.Behaviors.EditingCore.Behaviors.RowAdding.Row.Tag = "AddRow";
Client Code:
currentRow = eventArgs.getActiveCell().get_row();
alert('Is Add Row? ' + currentRow.get_tag() == "AddRow");
But the get_tag() method on the client is coming back as null even if the currentRow is the Adding row. Maybe I am setting the Tag in the wrong place, but I have tried three places so far with no luck. Thoughts? Is another way to determine if the current row is the add row?
Here is some additional code and question. My hope was that the commit method would trigger a server update and put whatever is in the Adding Row (if the user has put something in that row) up to the server. From my testing, I see this code does a good job of determining whether or not there is data in the Adding row and also whether or not the user has move off the adding row (say, by clicking on a different cell). If the user uses just the Tab and Enter keys, the Row Adding feature works fine, but it doesn't work so well when the user clicks on a different cell, for example.
Any ideas why this doesn't work for me?
Thank you,
Ross
function dgAdHocPayment_Activation_ActiveCellChanged(sender, eventArgs) {
///<summary>
///
///</summary>
///<param name="sender" type="Infragistics.Web.UI.WebDataGrid"></param>
///<param name="eventArgs" type="Infragistics.Web.UI.ActiveCellChangedEventArgs"></param>
addingRow = sender.get_behaviors().get_editingCore().get_behaviors().get_rowAdding().get_row();
currentColIndex = eventArgs.getActiveCell().get_column().get_index();
if ((currentRow.get_index() != addingRow.get_index() || currentColIndex > 5)
&& AddingRowHasData(addingRow)) {
sender.get_behaviors().get_editingCore().commit();
}
} // -->
editingCore.commit() only works if the row was already added via the add row (and it was batch updating). You need to tell the add row to commit its row.
rowAdding._commitRow();
-Davd
Beautiful, it works!! Thank you.