actually correct add_row_data index handling

This commit is contained in:
2026-06-08 21:48:32 +02:00
parent 73f038cc37
commit 5fbb942361
+9 -2
View File
@@ -91,15 +91,22 @@ class aggridx(ui.aggrid):
# update client
self.run_grid_method("setGridOption", "columnDefs", new_column_defs)
def add_row_data(self, rows, index=-1):
def add_row_data(self, rows, index=None):
"""
insert rows at the provided index,
with the default being appending at the bottom of the table
this operation maintains the current view on the data
"""
row_data = self.options["rowData"]
# update server without re-draw
with self.props.suspend_updates():
self.options["rowData"].extend(rows)
if index is not None and 0 <= index < len(row_data):
row_data[index:index] = rows
else:
row_data.extend(rows)
# update client
self.run_grid_method("applyTransaction", {"add": rows, "addIndex": index})