diff --git a/stand/aggridx.py b/stand/aggridx.py index dcb69c4..9cf5610 100644 --- a/stand/aggridx.py +++ b/stand/aggridx.py @@ -3,6 +3,15 @@ from nicegui import ui class aggridx(ui.aggrid): + #TODO: to be fully generic, this would also be needed for the other constructors + @classmethod + def from_pandas(cls, *args, index="index", options=None, **kwargs): + options = options or {} + options.setdefault(":getRowId", f"(params) => params.data.{index}") # set row ID to index column + res = super().from_pandas(*args, options=options, **kwargs) + res.index = index + return res + def set_cell(self, row_id, col_id, new_val): row_index = self.row_id_to_index(row_id) self.set_cell_server(row_index, col_id, new_val) diff --git a/stand/table.py b/stand/table.py index f5163ed..a0bbb49 100644 --- a/stand/table.py +++ b/stand/table.py @@ -8,7 +8,6 @@ from utils.annotations import PGroup OPTIONS = { - ":getRowId": "(params) => params.data.run", # set row ID to index column "context": { "beamline": None, "pgroup": None @@ -58,7 +57,7 @@ def table_show(pgroup, beamline): pgroup=pgroup ) - grid = aggridx.from_pandas(df, options=options) + grid = aggridx.from_pandas(df, index="run", options=options) grid.classes("h-[calc(100vh-2rem)]") # full height minus padding grid.on("cellValueChanged", update_adb) grid.on("cellValueChanged", update_grids)