# How to correctly implement getDataPath for Tree structures in Dash AG Grid (python)

**URL:** <https://community.plotly.com/t/how-to-correctly-implement-getdatapath-for-tree-structures-in-dash-ag-grid-python/89740>\
**Category:** Dash Python\
**Tags:** question\
**Created:** [January 5, 2025, 6:38pm UTC](https://community.plotly.com/t/how-to-correctly-implement-getdatapath-for-tree-structures-in-dash-ag-grid-python/89740 "2025-01-05T18:38:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![wcarpenter](https://avatars.discourse-cdn.com/v4/letter/w/ed655f/32.png) [@wcarpenter](https://community.plotly.com/u/wcarpenter)\
**Post date:** [January 5, 2025, 6:38pm UTC](https://community.plotly.com/t/how-to-correctly-implement-getdatapath-for-tree-structures-in-dash-ag-grid-python/89740/1 "2025-01-05T18:38:11Z")

</div>

I am trying to implement a data table that has a ‘tree structure’ such that the table is render with rows that have drop downs for additional rows (children). Below is a basic Dash app I have created and tried to run but the table appears blank and the console reports the following error “AG Grid: getDataPath() should not return an empty path for data [object Object]”. Can someone advise on the correct implementation?

Please note that an AG Grid enterprise key has to be provided to run this type of type of table.

```auto
import dash
from dash import Dash, html
from dash_ag_grid import AgGrid

app = Dash()

rowData = [
    {"orgHierarchy": ["Erica Rogers"], "jobTitle": "CEO", "employmentType": "Permanent"},
    {"orgHierarchy": ["Erica Rogers", "Malcolm Barrett"], "jobTitle": "Exec. Vice President", "employmentType": "Permanent"},
    {"orgHierarchy": ["Erica Rogers", "Malcolm Barrett", "Esther Baker"], "jobTitle": "Director of Operations", "employmentType": "Permanent"},
    {"orgHierarchy": ["Erica Rogers", "Malcolm Barrett", "Esther Baker", "Brittany Hanson"], "jobTitle": "Fleet Coordinator", "employmentType": "Permanent"},
    {"orgHierarchy": ["Erica Rogers", "Malcolm Barrett", "Esther Baker", "Brittany Hanson", "Leah Flowers"], "jobTitle": "Parts Technician", "employmentType": "Contract"},
    {"orgHierarchy": ["Erica Rogers", "Malcolm Barrett", "Esther Baker", "Brittany Hanson", "Tammy Sutton"], "jobTitle": "Service Technician", "employmentType": "Contract"},
    {"orgHierarchy": ["Erica Rogers", "Malcolm Barrett", "Esther Baker", "Derek Paul"], "jobTitle": "Inventory Control", "employmentType": "Permanent"},
    {"orgHierarchy": ["Erica Rogers", "Malcolm Barrett", "Francis Strickland"], "jobTitle": "VP Sales", "employmentType": "Permanent"},
    {"orgHierarchy": ["Erica Rogers", "Malcolm Barrett", "Francis Strickland", "Morris Hanson"], "jobTitle": "Sales Manager", "employmentType": "Permanent"},
    {"orgHierarchy": ["Erica Rogers", "Malcolm Barrett", "Francis Strickland", "Todd Tyler"], "jobTitle": "Sales Executive", "employmentType": "Contract"},
    {"orgHierarchy": ["Erica Rogers", "Malcolm Barrett", "Francis Strickland", "Bennie Wise"], "jobTitle": "Sales Executive", "employmentType": "Contract"},
    {"orgHierarchy": ["Erica Rogers", "Malcolm Barrett", "Francis Strickland", "Joel Cooper"], "jobTitle": "Sales Executive", "employmentType": "Permanent"},
]

grid = html.Div(
    [
        AgGrid(
            id="tree-data-example",
            columnDefs=[
                {"field": "jobTitle"},
                {"field": "employmentType"},
            ],
            defaultColDef={
                "flex": 1,
            },
            dashGridOptions={
                "autoGroupColumnDef": {
                    "headerName": "Organisation Hierarchy",
                    "minWidth": 300,
                    "cellRendererParams": {
                        "suppressCount": True,
                    },
                },
                "groupDefaultExpanded": -1,

                "getDataPath": "function(data) { return data.orgHierarchy; }",

                "treeData": True,
                "animateRows": False,
            },
            rowData=rowData,
            enableEnterpriseModules=True,
            licenseKey = DAG_KEY # an enterprise AG grid key needs to be added
        ),
    ]
)

app.layout = html.Div(
    [
        grid,
    ]
)

if __name__ == " __main__":
    app.run(debug=True)

```

---

<div class="post-metadata">

**Author:** ![AnnMarieW](https://avatars.discourse-cdn.com/v4/letter/a/ec9cab/32.png) [@AnnMarieW](https://community.plotly.com/u/AnnMarieW)\
**Post date:** [January 6, 2025, 12:21am UTC](https://community.plotly.com/t/how-to-correctly-implement-getdatapath-for-tree-structures-in-dash-ag-grid-python/89740/2 "2025-01-06T00:21:41Z")

</div>

Hi @wcarpenter and welcome to the Dash community 🙂

Try

```js
dashGridOptions={
  "getDataPath": {"function": "params.orgHierarchy"},

}

```

---

<div class="post-metadata">

**Author:** ![wcarpenter](https://avatars.discourse-cdn.com/v4/letter/w/ed655f/32.png) [@wcarpenter](https://community.plotly.com/u/wcarpenter)\
**Post date:** [January 6, 2025, 12:39am UTC](https://community.plotly.com/t/how-to-correctly-implement-getdatapath-for-tree-structures-in-dash-ag-grid-python/89740/3 "2025-01-06T00:39:48Z")

</div>

> [@AnnMarieW](#):
>
> `"getDataPath": {"function": "params.orgHierarchy"},`

Thanks for the follow up - should this work without any additional .js files? Aiming to build something out that doesn’t need to rely on one if I can avoid it.

---

<div class="post-metadata">

**Author:** ![AnnMarieW](https://avatars.discourse-cdn.com/v4/letter/a/ec9cab/32.png) [@AnnMarieW](https://community.plotly.com/u/AnnMarieW)\
**Post date:** [January 6, 2025, 3:57pm UTC](https://community.plotly.com/t/how-to-correctly-implement-getdatapath-for-tree-structures-in-dash-ag-grid-python/89740/4 "2025-01-06T15:57:26Z")

</div>

Did you try the solution I provided?

---

<div class="post-metadata">

**Author:** ![wcarpenter](https://avatars.discourse-cdn.com/v4/letter/w/ed655f/32.png) [@wcarpenter](https://community.plotly.com/u/wcarpenter)\
**Post date:** [January 11, 2025, 5:52pm UTC](https://community.plotly.com/t/how-to-correctly-implement-getdatapath-for-tree-structures-in-dash-ag-grid-python/89740/5 "2025-01-11T17:52:01Z")

</div>

Update - this worked … thank you!
