Deleting selected rows

Dear friends,

suppose I have the following frame

import pandas as pd
import numpy as np
import streamlit as st
from st_aggrid import AgGrid
testFrame=pd.DataFrame({"col1":["Albert","Mike","John","Laura"],"col2":["New York - Violation of Rule", "London", "Berlin - Violation of Rule", "Sao Paolo"]})

gb = GridOptionsBuilder.from_dataframe(testFrame)
        
        cellsytle_jscode = JsCode("""
function(params){
    if (params.value.includes('Violation of Rule')) {
        return {
            'color': 'red', 
            'backgroundColor': 'white',
        }
    }
}
""")
                                            
gb.configure_columns(testFrame, cellStyle=cellsytle_jscode,editable=True)
gb.configure_selection(use_checkbox=True,selection_mode="multiple")
grid_options = gb.build()
grid_return=AgGrid(testFrame, gridOptions=grid_options,allow_unsafe_jscode=True)

I managed to select multiple rows.

Question: How can I delete the selected rows? I used google, however without big success. Any support would be more than appreciated :slight_smile:

Hi @Isaak_Saba :wave:

Feel free to fork the code below:

It’s a simple demo I created showcasing how users can edit cells in a dataframe via the streamlit-aggrid component.

You can expand this code by adding a step to create a new dataframe without the selected rows.

I hope this helps - let me know how you go! :raised_hands:

Best,
Charly