:: Forum >>

adding a row to grid displays garbage

I have found that if sorting is selected by clicking on the header causes all new addd roww to be display garbage. My code is:
....
GridData.push(Row);
TheGrid.setCellText(GridData);
TheGrid.setRowCount(GridData.length);
TheGrid.refresh();
...
The code works if no sorting is selected. Anybody knows what am I doinmg wrong?

Adam Zielinski
Sunday, April 9, 2006
setRowCount would not be enough if you have changed the row order. You have to clear all row properties (incl. row indices array) - calling obj.clearRowModel(); - but in this case the sort order will be lost.

Instead you can call obj.addRow(i) method where i is the index of the new row.
Alex (ActiveWidgets)
Monday, April 10, 2006
Thanks Alex,

I have modified my code to:

....
GridData.push(Row);
TheGrid.addRow(GridData.length-1);
TheGrid.setCellText(GridData);
TheGrid.setRowCount(GridData.length);
TheGrid.refresh();
...

it does not display garbage anymore but add new element in the end instead of sorted order. The I added lines:

var Index = TheGrid.getSortColumn();
TheGrid.sort(Index, TheGrid.getSortDirection(Index));

before refresh. Did not help. Any suggestions, please?
Adam Zielinski
Wednesday, April 12, 2006
Sorry Alex,
Adding the sort works. I had a bug in my code. Additional line before Sort:
if (Index > 0)

Thanks
Adam
Adam Zielinski
Wednesday, April 12, 2006

This topic is archived.


Back to support forum

Forum search