I’m sure this will turn out to be a simple problem, but I can’t seem to figure it out.
I have a grid and a table.
Table implements a list of rows, and implements GetNumberRows() as len(therows).
Table implements InsertRows() as inserting a row in the data list and return True
The grid initializes and displays correctly with correct number of rows.
The problem is that grid does not update correctly on InsertRows(). What I see is that the blank row is inserted, rows are shifted down correctly, but last row falls off the grid because grid did not add a row to the display. I verified in a debugger that the data is correctly updated in the table, in this case the number of rows went from 21 to 22 and there is an empty default row at the correct location.
Behavior is as if grid.ForceRefresh() did not query table.GetNumberRows() to determine how many rows should be displayed.
Here is code in my grid class for inserting a row:
def rowInsertAt(self, row):
if row < 0:
return
print self.grid.Table.GetNumberRows() <--- prints 21, correct
ok = self.grid.InsertRows(row, 1)
self.grid.ForceRefresh()
print self.grid.Table.GetNumberRows() <--- prints 22, correct
Here is supporting code in table:
def GetNumberRows(self):
return len(self._data)
def InsertRows(self, row, n):
self._data[row:row] = [self._default_row] * n
return True
···
–
Mike Conley