How to get rowselected event in aggrid #778
Replies: 3 comments 10 replies
-
You can register grid.on('rowSelected', lambda msg: print(msg)) Output: {'id': 4, 'listener_id': '24f241a9-64a5-49c2-a752-7559dbee877e', 'args': {'rowIndex': 1, 'data': {'name': 'Bob', 'age': 21}, 'source': 'rowClicked', 'selected': True, 'rowHeight': 28, 'rowId': '1'}}
{'id': 4, 'listener_id': '24f241a9-64a5-49c2-a752-7559dbee877e', 'args': {'rowIndex': 0, 'data': {'name': 'Alice', 'age': 18}, 'source': 'rowClicked', 'selected': True, 'rowHeight': 28, 'rowId': '0'}}
... Regarding binding, somewhere else I wrote:
So I'm not sure how to make the selected rows bindable. |
Beta Was this translation helpful? Give feedback.
-
If "collections like lists and dictionaries are hard to bind in Python" and objects are not, then switching to (optionally) using objects as parameters to ui.elements might help introduce binding. For example instead of tree_data = [
{'id': 'numbers', 'children': [ ... ]},
{'id': 'letters', 'children': [ ... ]}
]
ui.tree(tree_data, ...) we instead create class TreeData:
...
class TreeItem:
...
ui.tree(TreeData(), ...) or something like that. The point is, changing e.g. |
Beta Was this translation helpful? Give feedback.
-
I am getting erratic results on this mygrid =ui.aggrid({'columnDefs':myColumnDefinitions, 'rowData': myDataRows, 'rowSelection': 'single'})
mygrid.on("rowSelected", lambda msg: self.handle_row_select(msg.args['data']))
def handle_row_select(self,record):
self.current_record = record
ui.notify(self.current_record) On every selection of row in grid by mouse click the notify give two rows the on that is currently selected and one that is newly selected |
Beta Was this translation helpful? Give feedback.
-
I'd like aggrid to support selection events, and
.bind_value()
. Currently the demos require the user click a button to extract the selected row, which is not ideal.The https://www.ag-grid.com/javascript-data-grid/row-selection/#selection-events show
Is there a way to get this into
ui.aggrid
?Beta Was this translation helpful? Give feedback.
All reactions