Docs

Tree Grid Recipes

Examples that combine Tree Grid features to solve common use cases.

This page contains examples that combine Tree Grid features to solve common use cases.

Highlighting a Subtree Flow

Custom part names can depend on the position of an item in the hierarchy. In the example below, selecting a row highlights all of its descendants with a selected-subtree part name. The part name generator checks whether the selected item is an ancestor of the rendered item. Because part names are generated only when a row is rendered, the selection listener refreshes the descendants of both the previously and the newly selected item.

Source code
TreeGridSubtreeHighlight.java
tree-grid-subtree-highlight.css
tree-grid-subtree-highlight.css

See Dynamically Styling Rows & Columns for more information about custom part names.

Selecting Children Recursively Flow

In multi-select mode, selecting a parent row selects only that row by default. To also select or deselect all of its descendants, handle the selection event and update the selection with the children of the changed items. The example below fetches the descendants from the data provider. Selection changes made on the server aren’t from the client, so the listener ignores them and doesn’t process its own updates.

Source code
TreeGridRecursiveSelection.java

See Grid Selection for more information about selection modes.

Updated –