index can be provided as argument and is used to define getRowId

This commit is contained in:
2026-06-12 22:04:06 +02:00
parent c8d15dcf1e
commit 18928f773b
2 changed files with 10 additions and 2 deletions
+9
View File
@@ -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)
+1 -2
View File
@@ -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)