AgGrid re-sizable virtual columns

I have a dropdown menu where users can select how many rows they want in their input table. I’m trying to implement the AgGrid virtual columns in such a way that the number of rows in the dataframe displayed corresponds to the number of rows specified in the dropdown menu. I’ve attatched a link for the virtual columns example.

I have been able to change the number of rows displayed in the code, however it does not do so dynamically when I change the input value in streamlit. It will take the initial value of the dropdown menu but it won’t update the table when I change the number of rows

Virtual Columns Example