Hello,
This question relates to IG version 10.3.20103.2134.
All the examples that I can find in the forums which use Delete functionality of the grid all use embedded datasources in their html markup. Due to security concerns, I am not able to do that. I bind the grid to a datasource in code behind just fine.
I implement the delete on the client side via:
function DeleteRow() { var grid = $find('<%= wgAgendaItems.ClientID %>'); var gridRows = grid.get_rows(); var selectedRows = grid.get_behaviors().get_selection().get_selectedRows(); for (var i = selectedRows.get_length() - 1; i >= 0; i--) { var row = selectedRows.getItem(i); gridRows.remove(row); } }
From what I can tell in the debugger, there are no script errors.
Here is the templated column in the grid:
<ig:TemplateDataField Key="DeleteItem" Width="80px"> <ItemTemplate> <asp:ImageButton ID="DeleteItem" ImageUrl="~/Images/icon_delete.gif" runat="server" AlternateText="Delete Icon" ToolTip="Delete Agenda Item" OnClientClick="DeleteRow(); return false;"/> </ItemTemplate></ig:TemplateDataField>
When this function runs I get an error and my code behind code which can actually perform the delete never gets called. The error is attached in a screen shot.
If anyone has a full example with binding to a collection of objects via code behind could you share?
Hello Alan,
Thank you for posting in the community.
I have been looking into the behavior that you have described and I suggest that you make sure you bind the grid to the data source on every postback by calling the DataBind() method, in order to ensure that the grid is databound in time for row deletion.
I’m attaching the sample I created.
Please let me know if you have any further questions.
Hi Alan,
Please let me know if you have any further questions on the matter.