index can be provided as argument and is used to define getRowId
This commit is contained in:
@@ -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
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user