PablocFonseca / streamlit-aggrid

Implementation of Ag-Grid component for Streamlit
https://pypi.org/project/streamlit-aggrid/
MIT License
1.05k stars 199 forks source link

With update 0.3.4 I cannot use pagination if I also set the height of the grid #200

Open Alessandro201 opened 1 year ago

Alessandro201 commented 1 year ago

I'm on version 0.3.4.post2.

If I set up the pagination while also choosing a grid height, the pagination will not show up. While, if I don't select any height, it works fine. On version 0.3.3 this issue is not present.

0.3.4

0 3 4 post2_img1 0 3 4 post2_img2

0.3.3

0 3 3_img1 0 3 3_img2

Possible causes

While trying to figure out why, I saw this line in init.py, which makes me think that this issue is the opposite of #97: https://github.com/PablocFonseca/streamlit-aggrid/blob/819e9a9bc85b316f1d686a354506a4cd50818d63/st_aggrid/__init__.py#L362-L365

In my case, if I don't set any height, dom_layout defaults to auto_height and pagination works. In that issue, if auto_height was set then it didn't.

Example code

This is the example code that generated the images above.

import pandas as pd
import streamlit as st

from st_aggrid import AgGrid, GridUpdateMode, JsCode
from st_aggrid.grid_options_builder import GridOptionsBuilder

test_data = [
    {"name": "1", "ip": "5.5.5.5"},
    {"name": "2", "ip": "5.5.5.6"},
    {"name": "3", "ip": "5.5.5.7"},
    {"name": "4", "ip": "5.5.5.7"},
    {"name": "5", "ip": "5.5.5.7"},
    {"name": "6", "ip": "5.5.5.7"},
    {"name": "7", "ip": "5.5.5.7"},
    {"name": "8", "ip": "5.5.5.7"},
    {"name": "9", "ip": "5.5.5.7"},
    {"name": "10", "ip": "5.5.5.7"},
    {"name": "11", "ip": "5.5.5.7"},
    {"name": "12", "ip": "5.5.5.7"},
    {"name": "13", "ip": "5.5.5.7"},
    {"name": "14", "ip": "5.5.5.7"},
    {"name": "15", "ip": "5.5.5.7"},
    {"name": "16", "ip": "5.5.5.7"},
    {"name": "17", "ip": "5.5.5.7"},
    {"name": "18", "ip": "5.5.5.7"},
    {"name": "19", "ip": "5.5.5.7"},
    {"name": "20", "ip": "5.5.5.7"},
]

height_param = {}
if  st.checkbox('Enable height', value=False):
    height = st.slider('Height', min_value=100, max_value=1000, value=500)
    height_param = {'height': height}

df = pd.DataFrame(test_data)

gb = GridOptionsBuilder.from_dataframe(df)
gb.configure_pagination(enabled=True)
gb.configure_grid_options()

gridOptions = gb.build()

grid_table = AgGrid(gridOptions=gridOptions,
                    configure_side_bar=True,
                    update_on=['modelUpdated'],
                    data=df,
                    **height_param)

# Print streamlit-aggrid module version
from importlib.metadata import version
st.write('Streamlit-aggrid version:', version('streamlit-aggrid'))
robingie commented 1 year ago

+1

vz-chameleon commented 1 year ago

+1 ! Out of curiosity and reproductiibility, what streamlit version are you using ?

For me, with streamlit==1.21.0 and streamlit==1.22.0, going to streamlit-aggrid==0.3.3 solves the pagination issue, but creates another one with the "ExcelBlob' key in AgGrid, on multiple selection.., can't figure out why....

image

gururise commented 1 year ago

Has anyone found the root cause?

nicomunting commented 9 months ago

It appears that the issue described here is related to #210 and can be solved with the solution described there.