3.2.0

how to delete row from sorted grid

I am not sure what is the purpose of the deleteRow method. To delete a row from sorted grid I came up with the code:

var Row = TheGrid.getCurrentRow();
var SortIndex = TheGrid.getRowIndices();
if (SortIndex)
{
SortIndex.splice(TheGrid.getRowPosition(Row), 1);
var offset = TheGrid.getRowOffset();
for(var i = 0; i < SortIndex.length; ++i)
if (SortIndex[i] > Row + offset)
--SortIndex[i];
TheGrid.setRowIndices(SortIndex);
}
GridData.splice(Row, 1);

Is there a simpler method? Should not the deleteRow method handle it? I found that the following code will not work.

var Row = TheGrid.getCurrentRow();
TheGrid.deleteRow(Row);
GridData.splice(Row, 1);

Adam Zielinski
April 12,
You should use deleteRow(index) method to tell the grid that the row with this index should no longer be rendered. The grid removes the given index from the array of row indices. However you should not remove the row from you js array, otherwise all row indices will change!
Alex (ActiveWidgets)
April 13,
Thanks Alex for prompt response.

Unfortunately I cannot afford to not remove the item from the JS array. In my business logic I have used two grids to construct dual select. The user by moving items between grids makes selection. Now if the user will move the same item couple of times between the grids in reality he will have lots of duplicates without knowing (seeing) it. I need to keep the JS array as tidy as the internal indices are.

Thanks
Adam
Adam Zielinski
April 13,
Adam,

I guess you are trying to make something like this example -

http://www.activewidgets.com/javascript.forum.13420.0/example-move-rows-between-two.html

I just put it in separate topic to make more visible.
Alex (ActiveWidgets)
April 13,
Hi Alex,

Thank you for a new approach. I would have to look what it takes for your algorithm to re-edit existing two sets of data. Unfortunately the project is already in QA and I cannot afford to redesign my original approach in current release.

Tanks again
Adam
Adam Zielinski
May 1,

This topic is archived.

See also:


Back to support forum