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.write(“”)
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)
st.write(“”)
# get filter data
data_filtered = filter_data(data_table, ss.filter_input)

   selected_row = draw_grid(
            data_filtered,
            formatter=set_grid_format(),
            fit_columns=True,
            selection='single'
   )
   ss.selected_data = selected_row.selected_rows

   print(ss.selected_data)

This print works perfectly if I delete the if condition but so this print show nothing and the front restart without the table data.
@PablocFonseca
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: