Hi, I am trying to delete a row in a WebHierarchicalDataGrid and I cannot figure out how to disable the auto postback that occurs. All I want to do is remove the row from grid on the client. I do not want any request sent back to the server.
I am following the client code from http://samples.infragistics.com/aspnet/Samples/WebDataGrid/Editing-and-Selection/Delete-Rows-Basic-Features/Default.aspx?cn=data-grid&sid=8ad22332-bd3a-4fdf-ba35-e3f4d8c49b9b which has the following line:
grid.get_behaviors().get_editingCore().get_behaviors().get_rowDeleting().deleteRows(rows);
When this line gets executed in my code a postback occurs. The only thing even close that I have found to disable anything is to attach into the client side row deleting handler and set the eventArgs.Cancel property to true. The problem with that is the row never gets deleted since I just canceled the entire row deletion operation. This is very frustrating. I just want to delete a row on the client.
Hi bartsipes,
you could use Batch Updating http://samples.infragistics.com/aspnet/Samples/WebHierarchicalDataGrid/EditAndSelection/BatchUpdating/Default.aspx?cn=hierarchical-data-grid&sid=29a3e22c-ccc7-4214-a7bb-006c13c7b0ea
Hope this helps
Thanks for the idea, but that only marks the row for deletion and adds an undo button that I do not want.
Hello bartsipes,
The sample you are looking uses WebDataGrid and the following line:
should be:
grid.get_gridView().get_behaviors().get_editingCore().get_behaviors().get_rowDeleting().deleteRows(rows);
If the grid’s Ajax is enabled then it shouldn’t make full post back.
I suggest you to look at the online samples for WebHierarchicalDataGrid , Delete Parent Row
<script type="text/javascript"> function DeleteRow() { var grid = $find('<%= this.whdg1.ClientID %>'); var gridRows = grid.get_gridView().get_rows(); var selectedRows = grid.get_gridView().get_behaviors().get_selection().get_selectedRows(); for (var i = selectedRows.get_length() - 1; i >= 0; i--) { var row = selectedRows.getItem(i); gridRows.remove(row); } } </script>
Thanks for the link to "Delete Parent Row". That code is simpler. However, enabling Ajax does not remove the post back. It only causing the post back to occur asynchronously from which I then get a null reference exception being passed back from the server regarding the handling of the row deletion on the server side that I do not care about.
var selectedRows = grid.get_gridView().get_behaviors().get_selection().get_selectedRows(); for (var i = selectedRows.get_length() - 1; i >= 0; i--) { var row = selectedRows.getItem(i); gridRows.remove(row); }
Hi,
You could switch the EditingCore to AutoCRUD="false", then you need to handle rowDeleting and do the delete yourself. Maybe that will solve your problem.
-Dave
Thanks David, I will give that a shot.
In the scenario I am working with I'm migrating from the old UltraWebGrid to the WebHierarchicalDataGrid. Using the old grid I intercept the deletion on the row and have some explicit (non-postback) JS code that performs an Ajax call back to the server to delete the row in the data source. From what you describe I think I could improve this process by handling the server event that gets fired by WebHierarchicalDataGrid when I delete a row. The problem with this scenario is that I am binding to an IEnumerable colletion as described in http://blogs.infragistics.com/blogs/alex_kartavov/archive/2010/04/08/binding-webhierarchicaldatagrid-to-ienumerable.aspx.
Right now if I let the postback occur when Ajax is enabled on my WebHierarchicalDataGrid, an Ajax call is made an the control pops up a Javascript alert window describing a null reference exception that occured on the server side (It seems to have a problem in the reflection code trying to find the "Remove" method on the collection). Is there a way to handle data source deletion events when the grid is bound to an IEnumerable collection so that I can perform the proper deletion logic?
This is a server control and therefore does deletes from the datasource there. We need the postback to accomplish this. If you're interested in a pure client grid, you could use our jQuery suite's igGrid. Another option is to turn on EnableClientRendering. You could then handle rowsDeleting client event to take the row out of the client 'data source' and rebind on the client. This would get of the row, but it would be up to you to actually delete from your data source.
regards,David Young