Skip to main content

Tree Data

To enable Tree Data, set .treeData(true) and configure the field mappings needed to traverse the hierarchy.

MethodTypeRequiredDescription
treeDatabooleanYesEnables Tree Data mode.
primaryFieldNameStringYesName of the entity's unique ID field. Matches field used in getServerSideGroupKey callback.
isServerSideGroupFieldNameStringYesName of the virtual boolean field indicating if a row has children. Matches field used in isServerSideGroup callback.
treeDataParentReferenceFieldStringConditionalName of the parent entity field. Required if not using treeDataParentIdField.
treeDataParentIdFieldStringConditionalName of the raw parent ID column. Required if not using treeDataParentReferenceField.
treeDataChildrenFieldStringNoName of the child collection field.
treeDataDataPathFieldNameStringNoThe name of the column storing the path string. Use if you want to utilize standard tree filtering.
treeDataDataPathSeparatorStringNoThe string separator used in your path. For example, in path 1/2/3, this would be /.

Example:

this.queryBuilder = QueryBuilder.builder(Entity.class, entityManager)
.colDefs(
// colDefs
)

// turn on treeData
.treeData(true)

// name of Id field in your entity (required)
.primaryFieldName("tradeId")

// name of field in which we return whether has children (required)
.isServerSideGroupFieldName("hasChildren")

// name of field that references to father (provide one of them)
.treeDataParentReferenceField("parentTrade") // mapped father entity
// .treeDataParentIdField("parentTradeId") // just ID

// name of field which holds child collection (optional)
.treeDataChildrenField("childTrades")
.build();
  • Source code for this grid available here
  • Backend source code available here
Loading grid...

Providing Child Counts

warning

To make providing child counts work, you need to provide treeDataDataPathFieldName parameter.

When showing child counts with Tree Data, the child count is a count of all descendants, including groups.

To receive child counts for groups, you need to set getChildCount param to true and provide property name getChildCountFieldName in which server returns the count.

  • Source code for this grid available here
  • Backend source code available here
Loading grid...

Aggregations on Tree Data

warning

To make aggregation on tree data work, you need to provide treeDataDataPathFieldName parameter.

You can get aggregates on group-level nodes the same way as with regular grouping.

  • Source code for this grid available here
  • Backend source code available here
Loading grid...

Filtering Tree Data

When filtering Tree Data in Server-Side Row Model, the adapter follows the standard AG Grid filtering logic.

A group will be included if:

  1. it has any children that pass the filter, or
  2. it has a parent that passes the filter, or
  3. its own data passes the filter
warning

To make filtering of tree data work as expected, you need to provide treeDataDataPathFieldName parameter.

  • Source code for this grid available here
  • Backend source code available here

Ignore Filters when Aggregating Values

When using Tree Data and filters, the aggregates are only calculated from the rows which pass the filter. This can be changed by enabling the queryBuilder option suppressAggFilteredOnly.