-
How do we access the selected rows (checkboxes) from Nice GUI? Start code from nicegui import ui
table = ui.table({
'columnDefs': [
{
'headerName': 'Athlete', 'field': 'athlete',
'headerCheckboxSelection': True,
'checkboxSelection': True,
'showDisabledCheckboxes': True,
},
{'headerName': 'Sport', 'field': 'sport'},
{'headerName': 'Year', 'field': 'year', 'maxWidth': 120},
],
'rowData': [
{'athlete': 'Alice', 'sport': 'soccer', 'year': 1980},
{'athlete': 'Bob', 'sport': 'golf', 'year': 1980},
{'athlete': 'Bill', 'sport': 'tennis', 'year': 2012},
],
'defaultColDef': {
'flex': 1,
'minWidth': 100,
},
'rowSelection': 'multiple',
'suppressRowClickSelection': True,
})
ui.run() |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Currently there is only limited support for AG Grid API methods, since JustPy's table.view.on('rowSelected', lambda _, msg: print(msg['rowIndex'], msg['selected'], flush=True)) |
Beta Was this translation helpful? Give feedback.
-
Thank you. table.view.on('cellValueChanged', checkBoxChanged)
def checkBoxChanged(sender, msg):
if msg.colId == 'enabled':
table.options.rowData[msg.rowIndex]['enabled'] = msg.newValue Then we printed all the rows in rowData that was set to true. if row['enabled']==True:
rowlist.append(row) |
Beta Was this translation helpful? Give feedback.
Thank you.
We did this:
Then we printed all the rows in rowData that was set to true.