3.2.0

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
April 9,
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)
April 10,
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
April 12,
Sorry Alex,
Adding the sort works. I had a bug in my code. Additional line before Sort:
if (Index > 0)

Thanks
Adam
Adam Zielinski
April 12,

This topic is archived.

See also:


Back to support forum