AgGrid

AgGrid is the main function used to render the grid.

AgGrid(dataframe: pandas.core.frame.DataFrame, gridOptions: typing.Optional[typing.Dict] = None, height: int = 400, width=None, fit_columns_on_grid_load: bool = False, update_mode: st_aggrid.shared.GridUpdateMode = GridUpdateMode.None, data_return_mode: st_aggrid.shared.DataReturnMode = 'as_input', allow_unsafe_jscode: bool = False, enable_enterprise_modules: bool = False, license_key: typing.Optional[str] = None, try_to_convert_back_to_original_types: bool = True, conversion_errors: str = 'coerce', reload_data: bool = False, theme: str = 'light', key: typing.Optional[typing.Any] = None, custom_css=None, **default_column_parameters) Dict[source]

Render the Grid Component using the ag-Grid JavaScript library and a dataframe.

Parameters
  • dataframe – The underlying dataframe to be displayed in the grid.

  • gridOption – A dictionary of options for ag-grid. Documentation on http://www.ag-grid.com If None default grid options will be created with GridOptionsBuilder.from_dataframe() call.

  • height – The grid height, by default 400

  • width

    Deprecated since version 0.2.0.

    The grid width, by default None

  • fit_columns_on_grid_load – Automatically fit columns to the grid width. Defaults to False.

  • update_mode

    Defines how the grid will send results back to streamlit. must be either a string, one or a bitwise combination of:

    • GridUpdateMode.NO_UPDATE

    • GridUpdateMode.MANUAL

    • GridUpdateMode.VALUE_CHANGED

    • GridUpdateMode.SELECTION_CHANGED

    • GridUpdateMode.FILTERING_CHANGED

    • GridUpdateMode.SORTING_CHANGED

    • GridUpdateMode.MODEL_CHANGED

    Note

    When using GridUpdateMode.MANUAL a save button will be drawn on top of grid.

    Note

    modes can be combined with bitwise OR operator | for instance: GridUpdateMode = VALUE_CHANGED | SELECTION_CHANGED | FILTERING_CHANGED | SORTING_CHANGED

    Defaults to GridUpdateMode.VALUE_CHANGED | SELECTION_CHANGED.

  • data_return_mode

    Defines how the data will be retrieved from components client side. One of:
    • DataReturnMode.AS_INPUT -> Returns grid data as inputed. Includes cell editions

    • DataReturnMode.FILTERED -> Returns filtered grid data, maintains input order

    • DataReturnMode.FILTERED_AND_SORTED -> Returns grid data filtered and sorted

    Defaults to DataReturnMode.AS_INPUT.

  • allow_unsafe_jscode – Allows javascript code to be injected in gridOptions. Defaults to False.

  • enable_enterprise_modules – Loads Ag-Grid enterprise modules (check licensing). Defaults to False.

  • license_key – License key for enterprise modules. Defaults to None.

  • try_to_convert_back_to_original_types – Attempts to convert back to original data types. Defaults to True.

  • conversion_errors

    Behaviour when conversion fails. One of:
    • ’raise’ -> invalid parsing will raise an exception.

    • ’coerce’ -> then invalid parsing will be set as NaT/NaN.

    • ’ignore’ -> invalid parsing will return the input.

    Defaults to ‘coerce’.

  • reload_data – Force AgGrid to reload data using api calls. Should be false on most use cases. Defaults to False.

  • theme

    Theme used by ag-grid. One of:
    • ’streamlit’ -> follows default streamlit colors

    • ’light’ -> ag-grid balham-light theme

    • ’dark’ -> ag-grid balham-dark theme

    • ’blue’ -> ag-grid blue theme

    • ’fresh’ -> ag-grid fresh theme

    • ’material’ -> ag-grid material theme

    Defaults to ‘light’.

  • key (typing.Any, optional) – Streamlit key argument. Check streamlit’s documentation. Defaults to None.

  • convenience (For) –

  • defaultColDef. (additional keyword arguments will be merged to gridOptions) –

Returns

A dictionary with members: data -> grid’s data, including edited values. selected -> list of selected rows

Return type

dict