Setting height of `ipyaggrid` in Solara app gives error
Hi, how can I set the
height
of a ipyaggrid
that is being cross-filtered by a solara
component? I am using @MaartenBreddels 's snippet here https://discord.com/channels/1106593685241614489/1106593686223069309/1212429587867504730. However, if I pass an integer height
to the grid element like this ipyaggrid.Grid.element(..., height=500)
it renders fine but then leads to this error: trait of a Grid instance expected a unicode string, not the int 500
, whenever the data is filtered. Could it be a bug in ipyaggrid
where the widget expects height
to be an int
but the trait is defined as unicode
, leading to data type issues? I found a workaround but wonder if I am missing something or if there is a better approach. Thanks!
6 Replies
Hi @Cyrus, ipyaggrid uses ipywidgets in a non standard way. It has a constructor that takes some arguments named the same as the traits and does some conversions on them. This indeed doesn't work so well with Solara. Your workaround looks good. We may at some point make a Solara component for ipyaggrid to deal with these issues.
@mariobuikhuizen thanks for the info. A Solara AgGrid component would be great to have indeed. I can add that in the feature-requests section if you'd like to track it
see also https://github.com/widgetti/solara/pull/531 - which explicitly mentions ipyaggrid, I think we should merge and publish this soon
maartenbreddels
<:pull_open:882464248721182842> [widgetti/solara] docs: document better how to use classical ipywidgets in components
We also give specific examples for ipyaggrid and ipydatagrid which
are quite popular with solara.
Based on discussion on discord and:
https://github.com/widgetti/solara/issues/512
https://github.com/widgetti/solara/issues/511
TODO:
- ◻️ examples in markdown don't always work well.
Created
Or do you think we should extend this a bit @Cyrus ?
@MaartenBreddels These docs are very helpful so merging soon would be ideal. You could mention the
height
issue above but I feel like maybe it is best for that to come in a future release where you'd create a Solara component for ipyaggrid
to fix that, as Mario suggested.
Hi, I extended the above so that AgGrid
can also take in menu
as kwarg
I assume this workaround generalizes to every trait that gets converted? Let me know if you can think of a better approach! Thanks