DevExtreme Angular - Access the DataSource

Regardless of the data source you use, the TreeList always wraps it in the DataSource. To get a DataSource instance, call the getDataSource() method.

TypeScript
  • import { ..., ViewChild } from '@angular/core';
  • import { DxTreeListModule, DxTreeListComponent } from 'devextreme-angular';
  • // ...
  • export class AppComponent {
  • @ViewChild(DxTreeListComponent) treeList: DxTreeListComponent;
  • ds: any = {};
  • getDataSource () {
  • this.ds = this.treeList.instance.getDataSource();
  • }
  • }
  • @NgModule({
  • imports: [
  • // ...
  • DxTreeListModule
  • ],
  • // ...
  • })

You can now call any method exposed by the DataSource. For example, you can reload data using the reload() method.

JavaScript
  • ds.reload();
See Also