Ag grid with input search

I’m using AgGrid component in my app and I use too a search input to filter data.
First show only search input and button. When click on search button I show the data filter and I want when click row go to other page

But when I put the button click condition the click event on a row fail.
This is my code:

input_column, button_column = st.columns([11, 1])
ss.filter_input = input_column.text_input(“Para empezar, introduce una palabra clave para obtener información”, value=ss.filter_input)
if button_column.button(“Buscar”):
ss.search_clicked = True

if ss.search_clicked:
st.markdown(“Estos son los datos que coinciden con las búsqueda, pulsa sobre el que quieras más información”,unsafe_allow_html=True)
# get filter data
data_filtered = filter_data(data_table, ss.filter_input)

   selected_row = draw_grid(
   ss.selected_data = selected_row.selected_rows


This print works perfectly if I delete the if condition but so this print show nothing and the front restart without the table data.
If I quit the search clicked condition its works but I need show table only if the button search is clicked.
I don’t understand what is happening :face_with_raised_eyebrow: