Wrapping ipyaggrid properly #1020
Unanswered
scottcjohnston
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello all, firstly thanks to the maintainers, Solara has been super useful for my projects and its been a great experience overall!
I'm sharing my approach and experience with wrapping ipyaggrid for solara, hoping we can come up with a canonical approach to doing this as I think it would benefit the community. Increasingly with LLMs its important to have good examples for them to "learn" published somewhere (of course this helps humans as well!) hopefully I can help get people moving more quickly when looking for a more featured datagrid for solara.
The code below is my attempt so far, please go easy on it and think of it as a work in progress rather than the finished article, I have also made it suit my use-case its not supposed to be a generic wrapper. However I think it could be a useful starting point for the stated aim of having a canonical example people can adapt to their use-case.
Rough edges
passing an int, results in:
traitlets.traitlets.TraitError: The 'height' trait of a Grid instance expected a unicode string, not the int 200.
I think this leads to more general questions about wrapping IPywidgets and the kinds of issues faced. I don't completely understand what "element" is doing under the hood and where this issue migh be, but I'm doing my best to learn. Regardless the standard work-around appears to be to use "use_effect" and configure the trailet directly after rendering.
I wondered if anyone had thoughts on my approach to getting selection data out of the grid by attaching a reactive variable to the traitlet via "observe". Unfortunately doing this via "use_trait_observe" ran into issues and I couldn't get this working. As a side note, aggrid only returns the slection data thats "visible" and in my usecase I want to hide some column, I have a filtering approach but its prone to failures depending on the data as there might be multiple matches depending on the available "visible" columns.
minor one, I wondered if anyone has a method for forcing re-render of objects in response to a reactive variable change, for example the "theme" as I understand changing some traits will force a re-render but can we force it via another method?
Beta Was this translation helpful? Give feedback.
All reactions