-
-
Notifications
You must be signed in to change notification settings - Fork 492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added functions to get client data to AgGrid element #1079
Conversation
@BrianLandry Thanks a lot for this pull request! I finally found the time to have a look into it. The idea sounds very reasonable. Unfortunately, however, it doesn't seem to work. This is what I'm experimenting with: grid = ui.aggrid({
'columnDefs': [{'headerName': 'Name', 'field': 'name', 'editable': True}],
'rowData': [{'name': 'Alice'}, {'name': 'Bob'}, {'name': 'Carol'}],
})
async def get_data():
print(await grid.get_client_data())
ui.button('Get data', on_click=get_data) But it always prints the original data, ignoring any edits. |
Interesting. I’ll try to dive in this weekend and see whats up. I am using this code regularly and it’s definitely working. So its either a issue with how i moved it over to this code base. Or some more tricky setup specific bug. |
If I edit a cell, and then click the "Get Data" button I replicate your behavior. Hopefully, this is what was occurring on your end. This is because by default the AgGrid has the parameter To address this I can think of three options:
I'm leaning towards # 1. I don't think niceGUI should try to address bad defaults in AgGrid, even if it is causing a painpoint when using niceGUI, but it would be great to hear your thoughts. |
Thanks for the clarification, @BrianLandry! That might have been the problem. I added a note about |
When the client edits a cell in AgGrid the data is not automatically synced to the python dictionary backing the AgGrid element. To obtain that data this PR adds a helper function to the AgGrid element that executes javascript to obtain the rowData present on the client.
This PR would address this question from Discord and also is something I am using in my own work.
I plan to add tests, but am struggling to get Selenium working right now. I wanted to open this PR in the meantime to make sure there was interest in this feature. If so I'll work on getting the tests together.