I am a newbie, i’ll say that right up front. I am trying to set the width of a grid in pixels. Nothing seems to affect the width. I only have one column of text read in from a cvs file. The column of text correctly shrinks to the fits size - which is great. But the header for that one column extends far to the right as if there were several more columns - but of course there are not. This seem like it would be very easy… but its got me stumped.
To test you need to create a cvs file called sample.cvs and paste in the following 5 lines:
AIRLINE
United
Delta
Southwest
American
BTW is there no way to upload files other than images?
Here’s the py code:
import altair as alt
from itertools import cycle
from st_aggrid import GridOptionsBuilder, AgGrid, GridUpdateMode, DataReturnMode, JsCode
#replace path in the following line with actual path to sampe.cvs
df = pd.read_csv(‘/path/to/sample.csv’)
selection_mode = ‘multiple’
gb = GridOptionsBuilder.from_dataframe(df)
gb.configure_selection(selection_mode)
gb.configure_selection(selection_mode, use_checkbox=True)
gridOptions = gb.build()
grid_response = AgGrid(
df,
gridOptions=gridOptions,
height=500,
fit_columns_on_grid_load=True,
width=50,
data_return_mode=‘AS_INPUT’,
)
selected = grid_response[‘selected_rows’]
selected_df = pd.DataFrame(selected)