AG Grid deselectAll function not always working

I have an AG Grid table with checkbox multi-selection on and when you check a row it greats a plotly figure. I made a button that uses the deselectAll function to uncheck any rows that are selected, which does deselect the rows, and sometime it also clears the previously loaded figures (which i want) but most of the time it doesn’t despite the boxes being unchecked. Is there a way to make it consistently reset the figures? (streamlit 1.36)

js = JsCode(“”"
function(event) {
const api = event.api;
window.addEventListener(‘clear.rows’, (e) => {
api.deselectAll().then(() => {gridApi.onFilterChanged();})
});
}
“”")

if st.sidebar.button(‘:no_entry: Clear Row Selection’):
clearJs = ‘’‘<script.>
((e) => {
const iframe = window.parent.document.querySelectorAll(’[title=“st_aggrid.agGrid”]‘)[0] || null;
if(!iframe) return;
iframe.contentWindow.dispatchEvent( new Event(‘clear.rows’));
})()
</script.>
‘’’
components.html(clearJs)

gb1.configure_grid_options(onFirstDataRendered=js)

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.