delete array of row indexes

2 posts, 0 answers
  1. Armando Canez
    Armando Canez avatar
    5 posts
    Member since:
    Aug 2009

    Posted 07 May 2018 Link to this post

    I need to delete a bunch of rows for wich I have their respective CURRENT row indexes in an array.

    However if I do a sheet.deleteRow(rowIndex), The row indexes of the rest of the rows change.

     

    I can't find a way to reference the rows themselves. Only the row indexes.

     

    How could I go about doing such a task?

     

    I do not have Data binding of any kind.

    Thanks in advance.

     

     
    // this does not work. I need a reference to the row itself
     
    var rowsToDelete = [2,6,53];
     
    for (var x=0;x<rowsToDelete.length;x++){
     
    sheet.deleteRow(x);
     
    }

     

     

     

  2. Dimitar
    Admin
    Dimitar avatar
    796 posts

    Posted 09 May 2018 Link to this post

    Hello Armando,

    I have setup a sample Dojo, where the deleteRow() method is used to remove rows by index:
    <script>
      $("#del-rows").on("click", function(e) {
        var spreadsheet = $("#spreadsheet").data("kendoSpreadsheet");
     
        var sheet = spreadsheet.activeSheet();
        var rowIndexes = [ 2, 4, 6, 7, 10];
     
        sheet.batch(function() {
          for (var i = 0; i < rowIndexes.length; i += 1) {
            var indexToDelete = rowIndexes[i];
     
            sheet.deleteRow(indexToDelete);
          }
        }, { layout: true });
      });
    </script>

    The above approach is working correctly on my end. May I ask you to check the example and verify if everything is working correctly? In case this is not what you are looking for, please elaborate more on the exact use case.

    Regards,
    Dimitar
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top