Skip to content

groupAggFiltering not allowed to be function in the dashGridOptions #471

Description

@vivalf

Hello,

Following the documentation of ag grid regarding the filtering when using aggregation. I tried to use the "groupAggFiltering" in the grid options with a javascript function (see https://www.ag-grid.com/javascript-data-grid/aggregation-filtering/#configure-by-callback).

However, it seems that dash-ag-grid does not recognise groupAggFiltering as a possible JS function and the JS function is not executed.

Hence the provided example below does not execute the code in groupAggFiltering:



app = Dash()

df = pd.read_csv(
    "https://raw.githubusercontent.com/plotly/datasets/master/ag-grid/olympic-winners.csv"
)

columnDefs = [
    # Row group by country and by year is enabled.
    {
        "field": "country",
        "rowGroup": True,
        "hide": True,
        "suppressColumnsToolPanel": True,
    },
    {
        "field": "sport",
        "rowGroup": True,
        "hide": True,
        "suppressColumnsToolPanel": True,
    },
    {
        "field": "year",
        "pivot": True,
        "hide": True,
        "suppressColumnsToolPanel": True,
    },
    {"field": "gold", "sortable": True, "filter": True, "aggFunc": "sum"},
    {"field": "silver", "sortable": True, "filter": True, "aggFunc": "sum"},
    {
        "headerName": "ratio",
        "colId": "goldSilverRatio",
        "aggFunc": {"function": "ratioAggFunc(params)"},
        "valueGetter": {"function": "ratioValueGetter(params)"},
        "valueFormatter": {"function": "ratioFormatter(params)"},
    },
]

app.layout = html.Div(
    [
        dag.AgGrid(
            id="example",
            enableEnterpriseModules=True,
            columnDefs=columnDefs,
            rowData=df.to_dict("records"),
            dashGridOptions={groupAggFiltering":{"function":"!!params.node.group" }
        ),
    ]
)

I think this can be solved by adding groupAggFiltering to the list of GRID_MAYBE_FUNCTIONS in "propCategories.js".

Activity

  1. AnnMarieW commented on Jul 4, 2026

    @AnnMarieW
    Collaborator

    Hi @vivalf

    Thanks for reporting. Your proposed solutions is correct. 🎉
    We would welcome PR if you would like to do one.

    It's good to use an example from the ag grid docs for testing. Here's a dash version from the link you provided:

    from dash import Dash, html
    import dash_ag_grid as dag
    import pandas as pd
    
    df = pd.read_csv(
        "https://raw.githubusercontent.com/plotly/datasets/master/ag-grid/olympic-winners.csv"
    )
    
    app = Dash()
    
    column_defs = [
        {"field": "country", "rowGroup": True, "hide": True},
        {"field": "year"},
        {"field": "total", "aggFunc": "sum", "filter": "agNumberColumnFilter"},
    ]
    
    default_col_def = {
        "flex": 1,
        "floatingFilter": True,
    }
    
    auto_group_column_def = {
        "field": "athlete",
    }
    
    app.layout = html.Div(
        children=[
            dag.AgGrid(
                id="olympic-grid",
                rowData=df.to_dict("records"),
                columnDefs=column_defs,
                defaultColDef=default_col_def,
                dashGridOptions={
                    "groupAggFiltering": {"function": "!!params.node.group"},
                    "groupDefaultExpanded": -1,
                    "autoGroupColumnDef": auto_group_column_def,
                },
                enableEnterpriseModules=True,
            )
        ],
    )
    
    if __name__ == "__main__":
        app.run(debug=True)
    
    
  2. vivalf commented on Jul 5, 2026

    @vivalf
    ContributorAuthor

    Hello @AnnMarieW

    I tested the modifications of GRID_MAYBE_FUNCTIONS and this seems to make the groupAggFiltering work with functions.

    I'll try to do the PR and write a test based on the proposal you suggested (thank you) this week.

  3. AnnMarieW commented on Jul 6, 2026

    @AnnMarieW
    Collaborator

    Hi @vivalf

    That's great news! Please let me know if you have any questions about the test.
    It can be added to this file: https://github.com/plotly/dash-ag-grid/blob/main/tests/test_custom_filter.py

  4. vivalf commented on Jul 6, 2026

    @vivalf
    ContributorAuthor

    I opened a pull request (#472).
    This is my first one, so I'm waiting for your comments

  5. linked a pull request that will close this issueGroup agg filtering #472on Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions