Hi Everyone,
Is it possible to configure Dash AG Grid to filter columns by more than the the default 2 parameters (using AND / OR) without having an enterprise license? This seems to be one of the biggest draw backs with AG Grid.
Hi Everyone,
Is it possible to configure Dash AG Grid to filter columns by more than the the default 2 parameters (using AND / OR) without having an enterprise license? This seems to be one of the biggest draw backs with AG Grid.
Hello @kbally,
Yes, you should be able to create your own filter.
The default filters are limited to two, but I like you should be able to make it more with a custom one.
Or, make your own way to filter your data. Like a list or whatnot.
Hi @kbally
The default is 2, but you can have more. This example has not yet been added to the dash docs, but you can find out more info here:
Here’s an example with dash:
The following example demonstrates Filter Condition configuration that can be applied to any Simple Filter.
filterOptions
set to show a different list of available options, and defaultOption
set to change the default option selected.maxNumConditions
set to 10
so that up to ten conditions can be entered.numAlwaysVisibleConditions
set to 2
so that two conditions are always shown. The defaultJoinOperator
is also set to 'OR'
rather than the default ('AND'
).import dash_ag_grid as dag
from dash import Dash, html
import pandas as pd
app = Dash(__name__)
df = pd.read_csv(
"https://raw.githubusercontent.com/plotly/datasets/master/ag-grid/olympic-winners.csv"
)
columnDefs = [
{"field": "athlete"},
{
"field": "country",
"filterParams": {
"filterOptions": ["contains", "startsWith", "endsWith"],
"defaultOption": "startsWith",
},
},
{
"field": "sport",
"filterParams": {
"maxNumConditions": 10,
},
},
{
"field": "age",
"filter": "agNumberColumnFilter",
"filterParams": {
"numAlwaysVisibleConditions": 2,
"defaultJoinOperator": "OR",
},
"maxWidth": 100,
},
]
app.layout = html.Div(
[
dag.AgGrid(
rowData=df.to_dict("records"),
columnDefs=columnDefs,
defaultColDef={
"resizable": True,
"sortable": True,
"filter": True,
"minWidth": 150,
},
columnSize="sizeToFit",
),
]
)
if __name__ == "__main__":
app.run(debug=True)
dag-docs