Closed smolendawid closed 6 months ago
I was able to make your example work by setting reload_data=False (the default value). Why did you need to set this to true?
That's a good point, I didn't mention it.
Unfortunately, I need to set reload_data=True
because I have some checkboxes/sliders that filter the dataframe (for example I need to be able to select show only rows where A=='a'
checkbox that filters out some rows from dataframe df
and the table reflects it). If I want to be able to filter the table, I need to have reload_data=True
.
I was trying to create a workaround - I set reload_data=False and added some state to understand the table shape. When data was filtered and shape changed, I deleted the table component with del
operator and created it again. Unfortunately it didn't work, the table is somehow cached and del
operator doesn't really destroy it
Looks like you're using reload_data to "prevent" grid to reload between streamlit refreshs. If this is the case, try setting a fixed key instead. By design streamlit's components will not redraw if key is fixed.
@smolendawid, a workaround for your issue is to set the "key" argument of the AgGrid widget depending on your filter settings. For example you could just append your settings to a string. In this way it will not reuse the old one and create a new table when the settings change.
This workaround works, congrats you figured it out!
@PablocFonseca my issue is not a 'question' I think.
When the number of rows in the table is small and
reload_data=True
, the selection doesn't show upMinimal example to reproduce:
The row that is selected is printed but you can't see it in the UI