Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Anuj on Sep 16, 2008 05:09
open dhtmlx forum
Delete Row Form Grid


there are 20 rows in grid

Cell 1 value of match with Cell 1 of next row.

if i change the value of cell 1 of row 3 then all rows after that row must be deleted.

i use onEditCell method

if(ind==4)
{
strFromPlace=value;
for(i=mygrid.getRowIndex(mygrid.getSelectedId());i<=mygrid.rowsCol.length;i++)
{
if(mygrid.getSelectedId() < mygrid.getRowId(i))
{
var vcNextPlace=mygrid.cells(mygrid.getRowId(i),ind).getValue();
if(value != vcNextPlace)
{
// Changes in place remove all rows.
var answer = confirm("All rows after this will be removed?")
     if (answer)
     {
    
     var x= mygrid.rowsCol.length;
     for(;i<=x;i++)
     {
     alert(i);
     mygrid.deleteRow(mygrid.getRowId(i));
     }
     break;
     }
     else
     {
     mygrid.cells(id,ind).setValue(vcNextPlace);
     }
}
}
}
}

but all rows are not deleted
some rows are not deleted (even or odd)

How should i remove all rows after perticular row.

Thanks & Regards
Anuj Sharma
Answer posted by Support on Sep 17, 2008 03:02
You can try to use the following approach in order to delete all rows after the row with id = ID:

var start = grid.getRowIndex(ID) + 1;

var count= grid.getRowsNum();

for (var i  = start; i < count; i ++){

grid.deleteRow(grid.getRowId(start));

}