GridOptionsBuilder¶
The GridOptionsBuilder class may be used to help defining gridOptions dictionary.
Even though grid’s configuration can be done by passing a dictionary, it is recommended to use the GridOptionsBuilder.
- class st_aggrid.GridOptionsBuilder¶
Builder for gridOptions dictionary
- build()¶
Builds the gridOptions dictionary
- Returns:
a
dictcontaining the configured grid options- Return type:
Dict
- configure_auto_height(autoHeight=True)¶
Makes grid autoheight
- Parameters:
autoHeight (bool, optional) – enable or disable autoheight. Defaults to
True.
- configure_column(field, header_name=None, **other_column_properties)¶
Configures an individual column. Check https://www.ag-grid.com/javascript-grid-column-properties/ for more information.
- Parameters:
field (str) – field name, usually equals the column header.
header_name (str, optional) – Header name. Defaults to
None.**other_column_properties (Dict) – column props
- configure_columns(column_names=[], **props)¶
Batch configures columns. Key-pair values from props dict will be merged to colDefs which field property is in column_names list.
- Parameters:
column_names (List, optional) – Columns field properties. If any of colDefs matches
**propsdict is merged. Defaults to[].**props (Dict) – props
- configure_default_column(min_column_width=5, resizable=True, filterable=True, sortable=True, editable=False, groupable=False, sorteable=None, **other_default_column_properties)¶
Configure default column.
- Parameters:
min_column_width (int, optional) – Minimum column width. Defaults to
100.resizable (bool, optional) – All columns will be resizable. Defaults to
True.filterable (bool, optional) – All columns will be filterable. Defaults to
True.sortable (bool, optional) – All columns will be sortable. Defaults to
True.sorteable (bool, optional) – Backwards compatibility alias for
sortable. Overrides sortable if notNone.groupable (bool, optional) – All columns will be groupable based on row values. Defaults to
True.editable (bool, optional) – All columns will be editable. Defaults to
True.groupable – All columns will be groupable. Defaults to
True.**other_default_column_properties (Dict, optional) – Key value pairs that will be merged to defaultColDef dict. Check ag-grid documentation.
- configure_first_column_as_index(suppressMenu: bool = True, headerText: str = '', resizable=False, sortable=True)¶
Configures the first column definition to look as an index column.
- Parameters:
suppressMenu (bool, optional) – Suppresses the header menu for the index col. Defaults to
True.headerText (str, optional) – Header for the index column. Defaults to
"".resizable (bool, optional) – Make index column resizable. Defaults to
False.sortable (bool, optional) – Make index column sortable. Defaults to
True.
- configure_grid_options(**props)¶
Merges props to gridOptions
- Parameters:
props (Dict) – props dicts will be merged to gridOptions root.
- configure_pagination(enabled=True, paginationAutoPageSize=True, paginationPageSize=10)¶
Configure grid’s pagination features
- Parameters:
enabled (bool, optional) – Self-explanatory. Defaults to
True.paginationAutoPageSize (bool, optional) – Calculates optimal pagination size based on grid Height. Defaults to
True.paginationPageSize (int, optional) – Forces page to have this number of rows per page. Defaults to
10.
- configure_selection(selection_mode: str = 'single', use_checkbox: bool = False, header_checkbox: bool = False, header_checkbox_filtered_only: bool = True, pre_select_all_rows: bool = False, pre_selected_rows: list | None = None, rowMultiSelectWithClick: bool = False, suppressRowDeselection: bool = False, suppressRowClickSelection: bool = False, groupSelectsChildren: bool = True, groupSelectsFiltered: bool = True)¶
Configure grid selection features
- Parameters:
selection_mode (str, optional) – Either
'single','multiple'or'disabled'. Defaults to'single'.use_checkbox (bool, optional) – Set to
Trueto have checkbox next to each row.header_checkbox (bool, optional) – Set to
Trueto have a checkbox in the header to select all rows.header_checkbox_filtered_only (bool, optional) – If
header_checkboxis set toTrue, once the header checkbox is clicked, returned rows depend on this parameter. If this is set toTrue, only filtered (shown) rows will be selected and returned. If this is set toFalse, the whole dataframe (all rows regardless of the applied filter) will be selected and returned.pre_selected_rows (list, optional) – Use list of dataframe row iloc index to set corresponding rows as selected state on load. Defaults to
None.rowMultiSelectWithClick (bool, optional) – If
False, user must hold shift to multiselect. Defaults toTrueif selection_mode is'multiple'.suppressRowDeselection (bool, optional) – Set to
Trueto prevent rows from being deselected if you hold down Ctrl and click the row (i.e. once a row is selected, it remains selected until another row is selected in its place). By default the grid allows deselection of rows. Defaults toFalse.suppressRowClickSelection (bool, optional) – Suppress row selection by clicking. Useful for checkbox selection for instance. Defaults to
False.groupSelectsChildren (bool, optional) – When rows are grouped selecting a group select all children. Defaults to
True.groupSelectsFiltered (bool, optional) – When a group is selected filtered rows are also selected. Defaults to
True.
- configure_side_bar(filters_panel=True, columns_panel=True, defaultToolPanel='')¶
- configures the side panel of ag-grid.
Side panels are enterprise features, please check www.ag-grid.com
- Parameters:
filters_panel ((bool, optional) – Enable filters side panel. Defaults to
True.columns_panel (bool, optional) – Enable columns side panel. Defaults to
True.defaultToolPanel (str, optional) – The default tool panel that should open when grid renders. Either
"filters"or"columns". If value is blank, panel will start closed (default)
- static from_dataframe(dataframe, **default_column_parameters)¶
Creates an instance and initilizes it from a dataframe. ColumnDefs are created based on dataframe columns and data types.
- Parameters:
dataframe (pd.DataFrame) – a pandas DataFrame.
**default_column_parameters (Dict) – default column parameters
- Returns:
The instance initialized from the dataframe definition.
- Return type: