Aggrid Component - How to reset data while selecting a different option, so that the previously entered value is not displayed?


I’m utilizing the Aggrid component to enable users to enter a set of values into a table and store them to a database. After entering a value for one item key based on three user-selectable filters, the next item key displays the identical value I submitted previously. I desire to see empty fields, not the values I used in a prior key.

### Steps to reproduce
import streamlit as st
import pandas as pd
from st_aggrid import AgGrid
from st_aggrid.grid_options_builder import GridOptionsBuilder
from data import get_main_table_df, get_Columns_Table_df, insert_into_outputTable,get_matching_data
import numpy as np

class Page2():
    def content():
        df = get_main_table_df()
        df = df.replace('', np.nan, regex=True)
    # Category selection
    categories = df['CATEGORY'].dropna().unique()
    category_selected = st.sidebar.selectbox(
            "Select Category",
    # subcategory selection
    sub_categories_filtered = df[df['CATEGORY'] == category_selected]
    sub_categories = sub_categories_filtered['SUB_CATEGORY'].dropna().unique()
    subCategory_selected = st.sidebar.selectbox(
            "Select Sub-Category",
    # item code selection
    item_code_filtered = sub_categories_filtered[sub_categories_filtered['SUB_CATEGORY'] == subCategory_selected]
    item_codes = item_code_filtered['ITEM_KEY'].dropna().unique()
    itemCode_selected = st.sidebar.selectbox(
            "Select ITEM_KEY",
    # filtering Columns Table
    df2 = get_Columns_Table_df()
    categ_subcateg_filtered_cols = df2.loc[(df2['Main Category'] == category_selected) & (df2['Sub-Category'] == subCategory_selected)]
    # if the filtered df is empty
    if categ_subcateg_filtered_cols.empty:
        columns_list = []
        columns_list = categ_subcateg_filtered_cols['Column_names'].values[0]
        columns_list = [f'"{item.strip()}"' for item in columns_list.split(',')]

    if len(columns_list) == 0 or len(columns_list) == 1:
        grid_table_df = pd.DataFrame()
        editable_cols = get_matching_data(itemCode_selected, columns_list)
        grid_table_df = pd.DataFrame(editable_cols)

    # datatable settings

    gb = GridOptionsBuilder.from_dataframe(grid_table_df)
    gb.configure_default_column(min_column_width=5, resizable=True, editable=True,groupable=True,
                                value=True, enableRowGroup=True, wrapText=True, autoHeight=True)

    gridOptions =

    grid_return = AgGrid(grid_table_df, gridOptions=gridOptions)

    # button to save entered data
    if st.button('Save Data'):
        new_df = grid_return['data']
        data_d = pd.DataFrame({'ITEM_KEY': [itemCode_selected], 'CATEGORY': [category_selected], 'SUB_CATEGORY': [subCategory_selected]})
        final_df = pd.concat([data_d, new_df], axis=1)
        # final_df = final_df.replace('', ' ', regex=True)
        final_dict = final_df.to_dict('records')[0]
        insert_into_outputTable(final_dict, itemCode_selected)
        st.success('Data Successfully Inserted!')

Here, I enter a value for a certain item key, but when I navigate to an other item key, the columns are already populated with values from the previous key. What I am expecting to see is blank fields.

Desperately in need of a help here, Thankyou

@PablocFonseca Dear Pabloc, could you pretty please guide me on the above!