Skip to main content

TreeViewItem Class

A Tree View dashboard item that allows end users to filter other dashboard items.

Declaration

export class TreeViewItem extends FilterElementItemBase

Remarks

The Tree View dashboard item displays values hierarchically and allows end users to filter other dashboard items by selecting parent/child values.

wdd-TreeView

The Tree View dashboard item does not support self-reference or parent-child hierarchies. The number of dimensions added to the Tree View item determines the number of levels in the hierarchy. Each level contains unique values from the corresponding level dimension. Values in each level are grouped by values in the previous dimension.

Refer to Filter Elements Overview to learn more about filter elements.

Example

The following example shows how to create the Tree View dashboard item, bind it to data and add to the existing dashboard.

Create data items (dimensions) and use the DataItem.dataMember property to bind them to the existing data source’s columns. Then use the created dimensions in the dashboard item to bind it to data.

After you add the created dashboard item to the Dashboard.items collection, call the Dashboard.rebuildLayout method to rebuild the dashboard layout and display changes.

// Use the line below for a modular approach:
// import * as Model from 'devexpress-dashboard/model'
// Use the line below for an approach with global namespaces:
// var Model = DevExpress.Dashboard.Model;

// ...
public creatTreeView() { 
    // Create data items for the TreeView.
    var treeViewYear = new Model.Dimension();
    treeViewYear.dataMember("OrderDate");
    treeViewYear.dateTimeGroupInterval('Year');
    var treeViewMonth = new Model.Dimension();
    treeViewMonth.dataMember("OrderDate");
    treeViewMonth.dateTimeGroupInterval('Month');

    // Create TreeView
    var treeViewItem = new Model.TreeViewItem();
    treeViewItem.name('treeView');
    treeViewItem.dataSource(sqlDataSource.componentName());
    treeViewItem.dataMember(sqlDataSource.queries()[0].name());

    treeViewItem.filterDimensions.push(treeViewYear);
    treeViewItem.filterDimensions.push(treeViewMonth);  

    treeViewItem.autoExpand(true);

    control.dashboard().items.push(treeViewItem);
    // ...
    control.dashboard().rebuildLayout();
}
See Also

constructor

Initializes a new instance of the TreeViewItem class.

Declaration

constructor(
    dashboardItemJSON?: any,
    serializer?: DevExpress.Analytics.Utils.ModelSerializer
)

Parameters

Name Type Description
dashboardItemJSON any

A JSON object used for dashboard deserialization. Do not pass this parameter directly.

serializer ModelSerializer

An object used for dashboard deserialization. Do not pass this parameter directly.

Properties

autoExpand Property

Specifies whether tree view nodes are expanded by default.

Declaration

autoExpand: ko.Observable<boolean>

Property Value

Type Description
Observable<boolean>

true, to expand tree view nodes by default; otherwise, false.