GridOptionsBuilder¶
The GridOptionsBuilder class may be used to help defining gridOptions dictionary. Eventhough grid’s configuration can be done by passing a dictionary, it is recommended to use the GridOptionsBuilder.
- class GridOptionsBuilder[source]¶
Auxiliary class that builds gridOptions dictionary.
Use this class to help AgGrid configuration. Any configuration supported by the gridOptions dictionary can be configured using this class. check https://www.ag-grid.com/javascript-grid-properties/ for more information.
- static from_dataframe(dataframe: pandas.core.frame.DataFrame, **default_column_parameters)[source]¶
Initializes a GridOptionsBuilder from a pandas dataframe.
This method creates a column definition for each column in the dataframe and tries to ifer correct columnTypes from dataframe’s dtypes.
- Parameters
dataframe – Dataframe to be used to create the GridOptionsBuilder.
**default_column_parameters – Key-pair values that will be merged to defaultColDef dict.
- Returns
A GridOptionsBuilder instance.
Example:
#builds a gridOptions dictionary using a GridOptionsBuilder instance. builder = GridOptionsBuilder.from_dataframe(df) builder.configure_column("first_column", header_name="First", editable=True) go = builder.build() #uses the gridOptions dictionary to configure AgGrid behavior. AgGrid(df, gridOptions=go)
- configure_default_column(min_column_width: int = 5, resizable: bool = True, filterable: bool = True, sorteable: bool = True, editable: bool = False, groupable: bool = False, **other_default_column_properties: dict)[source]¶
Sets default columns definitions.
More info here
- Parameters
min_column_width – minimum column width. Defaults to 5.
resizable – sets columns as resizable. Defaults to True.
filterable – sets columns as filterable. Defaults to True.
sorteable – sets columns as sorteable. Defaults to True.
editable – sets columns as editable. Defaults to False.
groupable – sets columns as groupable. Defaults to False.
**other_default_column_properties – Aditional keyword arguments values will be added as default columns definition.
- Returns
None
- configure_auto_height(autoHeight: bool = True)[source]¶
Configures auto height behavior.
- Parameters
autoHeight (
bool, optional
) – enable or disable auto height. Defaults to True.- Returns
None
- configure_columns(column_names: List[str] = [], **props)[source]¶
Batch configures columns.
Key-pair values from props dict will be merged to colDefs which field property is present in column_names list.
- Parameters
column_names – Columns field properties. If any of colDefs mathces
**props
dict is merged. Defaults to [].- Returns
None
- configure_column(field: str, header_name: Optional[str] = None, **other_column_properties)[source]¶
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
) – [description]. Defaults to None.
- Returns
None
- configure_side_bar(filters_panel: bool = True, columns_panel: bool = True, defaultToolPanel: str = '')[source]¶
Configures the side bar.
- Parameters
filters_panel (
bool, optional
) – enable or disable filters panel. Defaults to True.columns_panel (
bool, optional
) – enable or disable columns panel. Defaults to True.defaultToolPanel (
str, optional
) – sets default tool panel either ‘columns’ or ‘filters’. Defaults to panel closed (“”)
- Returns
None
- configure_selection(selection_mode: str = 'single', use_checkbox: bool = False, pre_selected_rows: List[int] = [], rowMultiSelectWithClick: bool = False, suppressRowDeselection: bool = False, suppressRowClickSelection: bool = False, groupSelectsChildren: bool = True, groupSelectsFiltered: bool = True)[source]¶
Configure the grid selection behavior.
- Parameters
selection_mode – Either ‘single’, ‘multiple’ or ‘disabled’. Defaults to ‘single’.
use_checkbox – Enable or disable checkbox selection. Defaults to False.
pre_selected_rows – List of row indexes to be pre-selected. Defaults to [].
rowMultiSelectWithClick – If False user must hold shift to multiselect. Defaults to True if selection_mode is ‘multiple’.
suppressRowDeselection – Set to true to prevent rows from being deselected if you hold down Ctrl and click the row (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 to False.
suppressRowClickSelection – Supress row selection by clicking. Usefull for checkbox selection. Defaults to False.
groupSelectsChildren – When rows are grouped selecting a group select all children. Defaults to True.
groupSelectsFiltered – When a group is selected filtered rows are also selected. Defaults to True.
- Returns
None
- configure_pagination(enabled=True, paginationAutoPageSize=True, paginationPageSize=10)[source]¶
Configure grid’s pagination features
- Parameters
enabled – enable or disable pagination. Defaults to True.
paginationAutoPageSize – Automatically sets optimal pagination size based on grid Height. Defaults to True.
paginationPageSize – Forces page to have this number of rows per page. Defaults to 10.
- Returns
None
- configure_grid_options(**props: dict)[source]¶
Merges key-pair values to gridOptions dictionary.
Use this method to add any other key-pair values to gridOptions dictionary. A complete list of available options can be found in https://www.ag-grid.com/javascript-data-grid/grid-properties/
- Returns
None