Ag-Grid component with input support

Unfortunately grouping is not implemented yet. I’m having little time to work on the grid, because my job is really demanding from me over the past months… =/ I hope to be able to take a look at that soon.

@PablocFonseca that’s understandable! Should it theoretically be possible if I try and do it outside of the gridbuilder module, or is it related to your conversion between pandas and whatever input AG Gid needs? Also, it appears to be possible to group to some extent when using enterprise mode, so that’s something.

Thanks again.

The gridBuilder is just a helper function. Its output is a simple dictionary. You can create a dictionary following ag-grid Documentation and it should work.

For st-aggrid i was planing to convert multi-indexes to groups through a flag option on gridOptionsBuilder

@PablocFonseca understood, I will keep exploring - just in case anyone is struggling, I worked out how to include dropdown options for cell input like this:

# my_list_of_options = ['Option 1', 'Option 2', 'Option 3']
# gb.configure_column("field_name", editable=True, cellEditor='agSelectCellEditor', cellEditorParams={'values': my_list_of_options })

Separately, have you or anyone else experienced random times where the grid suddenly keeps reloading when a selection is made, even though the grid preferences are as in your examples. For example, have been times where I have reload_data=True and selections do persist after selected, but all of a sudden this now doesn’t work and I have to set reload_data=False. This is a problem because I have a function that saves input from streamlit UI components and is then supposed to reload the grid based on those inputs. Is there another way to do this? Think that’s all my questions, and again, such a great too.

1 Like

Hi @PablocFonseca, can the current st-aggrid implement a date picker in the cell as the following diagram?

1 Like

Hi… loving this streamlit component! I am having trouble getting back an input change. What am I doing wrong here:

import streamlit as st
import as px
from st_aggrid import AgGrid, GridOptionsBuilder, DataReturnMode

df =

gb = GridOptionsBuilder.from_dataframe(df)
gb.configure_column('sepal_width', editable=True)
grid_options =
grid_response = AgGrid(df, gridOptions=grid_options, data_return_mode='AS_INPUT', update_model='MODEL_CHANGE\

df = grid_response['data']

When I edit a cell in my table I get back and empty dataframe and the error:

ValueError: Value of 'x' is not the name of a column in 'data_frame'. Expected one of [] but received: sepal_width
File "/opt/conda/lib/python3.7/site-packages/streamlit/", line 319, in _run_script
File "/tmp/working/app/", line 51, in <module>
    title=f"Template: {temp}",
File "/opt/conda/lib/python3.7/site-packages/plotly/express/", line 64, in scatter
    return make_figure(args=locals(), constructor=go.Scatter)
File "/opt/conda/lib/python3.7/site-packages/plotly/express/", line 1831, in make_figure
    args = build_dataframe(args, constructor)
File "/opt/conda/lib/python3.7/site-packages/plotly/express/", line 1364, in build_dataframe
    args, wide_mode, var_name, value_name
File "/opt/conda/lib/python3.7/site-packages/plotly/express/", line 1166, in process_args_into_dataframe
    raise ValueError(err_msg)
1 Like

Hi @PablocFonseca thank you for your awesome work and effort put into this. I like to know if the st_aggrid column can take if conditions.

For example:
if value in CAlc Options == ‘$ / unit’, return df['Yield], else df[‘NIA’]


You could use some Js expression in valueGetter in a virtual column (check this example)

I do not know your use case, but i’d calculate everything in python first and use AgGrid to render the final dataframe. Seems easier.

1 Like

Thank you for your reply. The downside of using python first and render through AgGrid is the result column is not responsive based on the changes in Calc Options. I’ve look at the example scripts, it helps with the my calculation tab, but how would you use the valueGetter to have if conditions. Thank you very much.

Hi again @PablocFonseca, there still appears to be a bug with this somewhere surrounding row selection - sometimes, when I have selection enabled and reload_data=True, and select a row or edit a cell, Streamlit shows “Running…” in the top right corner and removes the selection or content you’ve edited.

loaded_data = pd.DataFrame({'Fruit':["Grape", "Apple"], 'Vegetable':["Carrot", "Green Bean"]})
gb = GridOptionsBuilder.from_dataframe(loaded_data)

gb.configure_default_column(groupable=True, value=True, enableRowGroup=True, aggFunc='sum', editable=True)

gb.configure_selection('multiple', use_checkbox=False, groupSelectsChildren=True, groupSelectsFiltered=True)
gridOptions =

main_grid_response = AgGrid(
    fit_columns_on_grid_load=True, # automatically fits all columns to be displayed in the grid in one view
    allow_unsafe_jscode=True, #Set it to True to allow jsfunction to be injected

Is there any way to solve this temperamental issue if I want this grid to update based on user input? For example, the idea is that a user will enter information in a form below, press submit, and this information should end up in the grid at the top, without the grid re-initialising. Thanks

can you add a customPercentFormat simular to customCurrencyFormat?

1 Like

Did anyone manage to figure this one out? I’m have trouble getting the JS function for the DatePicker in the app. Tried a lot of different methods (also tried including it inside the i-frame sinds it’s sandboxed) but keep running into the AgGrid “editor not registered” error.

1 Like

@PablocFonseca Thank you so much for the great component. I am not able to find any other component which just handles the selection of rows. I am trying for that purpose only.
I have one issue when I am using AgGrid on server hosted script 60-70% of time
“Your app is having trouble loading the st_aggrid.agGrid component.” this message came.
Please help me out in how can I make it more stable so that it will load all the time.
I am using this configure:
grid_response =AgGrid(df,
# enable_enterprise_modules=True,

@PablocFonseca, is it possible to apply a dark theme to the grid? I tried looking thru the AG Grid documentation on themes but couldn’t figure out how to use it. Thanks!

Hi @PablocFonseca - thanks so much for developing st_aggrid!

I started using streamlit version 0.84.0 today, and unfortunately there seems to be an incompatibility with the st_aggrid component. If I try to apply a filter in the interactive grid, I get an error: "TypeError: string indices must be integers". Rolling streamlit back to version 0.83 solved the issue.

I used the following function to generate the datatable. Has anyone else experienced this?

from st_aggrid import AgGrid, GridOptionsBuilder, DataReturnMode, GridUpdateMode

def interactive_datatable(df):
    Use st_aggrid to show well table in GUI with interactive sorting and filtering options.
    df: input dataframe
    Returns: dataframe of AgGrid output (including filtering via GUI)
    #set up aggrid display/interactivity options
    gb = GridOptionsBuilder.from_dataframe(df)
    gb.configure_default_column(groupable=True, value=True, enableRowGroup=True, aggFunc='sum', editable=False)
    gridOptions =
    #set up data return/update modes
    return_mode_value = DataReturnMode.__members__['FILTERED_AND_SORTED']
    update_mode_value = GridUpdateMode.__members__['FILTERING_CHANGED']
    data_return_mode = return_mode_value
    grid_data = AgGrid(df, 
    grid_data_df = pd.DataFrame(grid_data['data'])
    return grid_data_df

I had just found the same problem and posted about it.
There is an error already when selecting or editing a cell, even without any other logic in the app.
I tried the demo and this error appearing almost in any grid.

@maajdl I got a response from @andfanilo in this thread on the issue - the streamlit team is already working on a fix :slight_smile:

Hi! For some reasons, while displaying data frame in the input grid (editing mode), some of the columns appear empty and thus cannot be edited. To be precise, 2 columns with float values and 1 with integers are always empty, although in the original data frame they are not

This is especially strange, because other columns with floats, integers and dates in the same data frame are completely fine (they are displayed/can be edited). The code is simple:

grid_return = AgGrid(df, editable=True, reload_data=False)

What could be the source of the problem? Thanks!

@PablocFonseca Thank you so much for this fantastic invention. Just wondering is there any limitation in number of rows displaying. Im getting “RuntimeError: Data of size 50.7MB exceeds write limit of 50.0MB” error even though its around 6 MB. But it has 11000 rows. Any thoughts on this?

Hi @dxz6228 Any luck with getting selected rows? Im also having same sure. Not sure what is the solution for it. :frowning: