diff --git a/stand/aggridx.py b/stand/aggridx.py index 5a9aa43..3bab6a6 100644 --- a/stand/aggridx.py +++ b/stand/aggridx.py @@ -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})