How to deselect all rows in ui.table #150
-
Apologies, I am new at all this... I cannot figure out how to deselect all the rows in a ui.table. I see a deselect_rows() call in AgGrid, but have no idea how to call it. I tried call Any help would be appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Have you awaited the And it can only run after the page has been loaded. If you run the javascript call on button click or similar, this is obviously the case. If you need to do this on page creation, try the |
Beta Was this translation helpful? Give feedback.
-
You can use JustPy's AgGrid API to send commands via #!/usr/bin/env python3
from nicegui import ui
table = ui.table({
'columnDefs': [{'field': 'name'}],
'rowData': [
{'name': 'Alice'},
{'name': 'Bob'},
{'name': 'Carol'},
],
'rowSelection': 'multiple',
'rowMultiSelectWithClick': True,
}).classes('max-h-40')
async def deselect1():
await table.view.run_api('deselectAll()', table.page)
async def deselect2():
await ui.run_javascript(f'cached_grid_def["g{table.view.id}"].api.deselectAll()')
ui.button('Deselect 1', on_click=deselect1)
ui.button('Deselect 2', on_click=deselect2)
ui.run() |
Beta Was this translation helpful? Give feedback.
-
Since NiceGUI 1.0 you can deselect table rows as follows: ui.button('Deselect', on_click=lambda: table.call_api_method('deselectAll')) |
Beta Was this translation helpful? Give feedback.
Since NiceGUI 1.0 you can deselect table rows as follows: