Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
270
Delete all rows from WebHierarchicalGrid(client side)
posted

Hi,

My following javascript code is able to delete only last row in the Grid. Can you please let me know what's the issue?

<ig:WebHierarchicalDataGrid ID="WebHierarchicalDataGrid1" runat="server" Height="350px" >
<Behaviors>
<ig:EditingCore>
<Behaviors>
   <ig:RowDeleting />
</Behaviors>
   </ig:EditingCore>
</Behaviors>

 

<input type="button" name="name" value="Delete All Rows(Client Side)" onclick="DeleteAllRows();" />

function DeleteAllRows() {
    var grid = $find("<%=WebHierarchicalDataGrid1.ClientID %>");
    var parentGrid = grid.get_gridView();
    var gridRows = parentGrid.get_rows();
    var rowLength = gridRows.get_length();
    var i = 0;
    for (i = rowLength - 1; i > 0; i--) {
        var row=gridRows.get_row(i);
        gridRows.remove(row);
        }
}

Thanks

Vin

Parents
  • 29417
    Suggested Answer
    Offline posted

    Hello vin,

     Thank you for posting in our forum.

    In this case you need to use the deleteRows() method of the row deleting behavior. It accepts an array of rows so you can delete multiple rows in one request. For example you can iterate through all the rows and  add them to an array and the pass that to the delete rows method. 

    function DeleteAll() {
              var grid = $find("WebHierarchicalDataGrid1");
              var rowDeleting = grid.get_gridView().get_behaviors().get_editingCore().get_behaviors().get_rowDeleting();
              var array = new Array();
              for (var i = 0; i < grid.get_gridView().get_rows().get_length(); i++) {
                  var row = grid.get_gridView().get_rows().get_row(i);
                  array.push(row);
              }
              rowDeleting.deleteRows(array);
          }

     

    Let me know if you have any questions or concerns.

     

     

    Best Regards,

    Maya Kirova

    Developer Support Engineer II

    Infragistics, Inc.

    http://ko.infragistics.com/support

     

Reply Children
No Data