This is a migrated thread and some comments may be shown as answers.

delete array of row indexes

1 Answer 292 Views
Spreadsheet
This is a migrated thread and some comments may be shown as answers.
Armando Canez
Top achievements
Rank 1
Armando Canez asked on 07 May 2018, 04:42 PM

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);
 
}

 

 

 

1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 09 May 2018, 01:47 PM
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.
Tags
Spreadsheet
Asked by
Armando Canez
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or