How to use the @angular/material/tree.MatTreeFlattener function in @angular/material

To help you get started, we’ve selected a few @angular/material examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github angular / components / src / demo-app / tree / tree-demo.ts View on Github external
constructor(database: FileDatabase) {
    this.treeFlattener = new MatTreeFlattener(this.transformer, this.getLevel,
                                              this.isExpandable, this.getChildren);
    // For flat tree
    this.treeControl = new FlatTreeControl(this.getLevel, this.isExpandable);
    this.dataSource = new MatTreeFlatDataSource(this.treeControl, this.treeFlattener);

    // For nested tree
    this.nestedTreeControl = new NestedTreeControl(this.getChildren);
    this.nestedDataSource = new MatTreeNestedDataSource();

    database.dataChange.subscribe(data => {
      this.dataSource.data = data;
      this.nestedDataSource.data = data;
    });
  }
github notadd / ng-notadd / src / app / main / applications / roles-permissions / permissions / permissions.component.ts View on Github external
},
            {
                value: 'self-group',
                label: '本用户组的数据'
            },
            {
                value: 'self-group-subordinate',
                label: '本用户组及下属用户组的数据'
            },
            {
                value: 'all',
                label: '全部数据'
            }
        ];

        this.treeFlattener = new MatTreeFlattener(
            this.transformer,
            this.getLevel,
            this.isExpandable,
            this.getChildren
        );
        this.treeControl = new FlatTreeControl(this.getLevel, this.isExpandable);
        this.dataSource = new MatTreeFlatDataSource(this.treeControl, this.treeFlattener);

        database.dataChange.subscribe(data => {
            this.dataSource.data = data;
        });
    }
github angular / components / src / dev-app / tree / loadmore-tree-demo / loadmore-tree-demo.ts View on Github external
constructor(private _database: LoadmoreDatabase) {
    this.treeFlattener = new MatTreeFlattener(this.transformer, this.getLevel,
      this.isExpandable, this.getChildren);

    this.treeControl = new FlatTreeControl(this.getLevel, this.isExpandable);

    this.dataSource = new MatTreeFlatDataSource(this.treeControl, this.treeFlattener);

    _database.dataChange.subscribe(data => {
      this.dataSource.data = data;
    });

    _database.initialize();
  }
github angular / components / src / material-examples / tree-checklist / tree-checklist-example.ts View on Github external
constructor(private _database: ChecklistDatabase) {
    this.treeFlattener = new MatTreeFlattener(this.transformer, this.getLevel,
      this.isExpandable, this.getChildren);
    this.treeControl = new FlatTreeControl(this.getLevel, this.isExpandable);
    this.dataSource = new MatTreeFlatDataSource(this.treeControl, this.treeFlattener);

    _database.dataChange.subscribe(data => {
      this.dataSource.data = data;
    });
  }
github runbox / runbox7 / src / app / folder / folderlist.component.ts View on Github external
combo = null;
                }
                const e: ExtendedKeyboardEvent = event;
                e.returnValue = false;
                return e;
            }));
        try {
            const storedExpandedFolderIds = JSON.parse(localStorage.getItem('rmm7expandedfolderids'));
            if (storedExpandedFolderIds && storedExpandedFolderIds.length > 0) {
                this.storedexpandedFolderIds = storedExpandedFolderIds;
            }
        } catch (e) {}

        this.folders = this.messagelistservice.folderCountSubject;
        this.treeControl = new FlatTreeControl(this._getLevel, this._isExpandable);
        this.treeFlattener = new MatTreeFlattener(
            (node: FolderNode, level: number): FolderCountEntry => {
                return node.data;
            },
            this._getLevel,
            this._isExpandable,
            (node: FolderNode) => node.children
        );
        this.dataSource = new MatTreeFlatDataSource(this.treeControl, this.treeFlattener);

        const foldertreedataobservable = this.folders
            .pipe(
                map(folders => folders.filter(f => f.folderPath.indexOf('Drafts') !== 0)),
                map((folders) => {
                const treedata: FolderNode[] = [];

                let currentFolderLevel = 0;
github babsey / nest-desktop / src / app / view / tree-view / tree-view.component.ts View on Github external
constructor(private database: Database) {
    this.treeFlattener = new MatTreeFlattener(this.transformer, this._getLevel,
      this._isExpandable, this._getChildren);
    this.treeControl = new FlatTreeControl(this._getLevel, this._isExpandable);
    this.dataSource = new MatTreeFlatDataSource(this.treeControl, this.treeFlattener);

    database.dataChange.subscribe(data => this.dataSource.data = data);

  }
github angular / components / src / material-examples / tree-loadmore / tree-loadmore-example.ts View on Github external
constructor(private _database: LoadmoreDatabase) {
    this.treeFlattener = new MatTreeFlattener(this.transformer, this.getLevel,
      this.isExpandable, this.getChildren);

    this.treeControl = new FlatTreeControl(this.getLevel, this.isExpandable);

    this.dataSource = new MatTreeFlatDataSource(this.treeControl, this.treeFlattener);

    _database.dataChange.subscribe(data => {
      this.dataSource.data = data;
    });

    _database.initialize();
  }
github geli-lms / geli / app / webFrontend / src / app / course / course-detail / download-course-dialog / download-tree / download-tree.component.ts View on Github external
constructor(private dataSharingService: DataSharingService) {
    this.treeFlattener = new MatTreeFlattener(this.transformer, this.getLevel,
      this.isExpandable, this.getChildren);
    this.treeControl = new FlatTreeControl(this.getLevel, this.isExpandable);
    this.dataSource = new MatTreeFlatDataSource(this.treeControl, this.treeFlattener);
    this.course = this.dataSharingService.getDataForKey('course');
    this.dataSource.data = this.buildFileTree(this.preBuildJSON(), 0);
  }
github phucan1108 / letportal / src / web-portal / src / app / modules / portal / modules / builder / components / backup-builder / components / backup-selection.component.ts View on Github external
if (!!this.selectedEntities && this.selectedEntities.length > 0 && level > 0) {
            const found = _.find(this.selectedEntities, entity => entity.id === node.parentId)
            if (!!found) {
                selectableNode.checked = found == selectableNode.id
                if (selectableNode.checked) {
                    this.checkEntitieslistSelection.select(selectableNode)
                }
            }
        }

        return selectableNode;
    }

    treeControl = new FlatTreeControl(
        node => node.level, node => node.expandable);
    treeFlattener = new MatTreeFlattener(
        this.transformer, node => node.level, node => node.expandable, (node: SelectableBackupNode) => node.subShortModels);

    dataSource = new MatTreeFlatDataSource(this.treeControl, this.treeFlattener);
    
    hasChild = (_: number, node: BackupNode) => node.expandable || node.level === 0;
    hasSelected(node: BackupNode) {
        return this.checkEntitieslistSelection.isSelected(node)
    }
    onTreeChange($event, node: BackupNode) {
        this.checkEntitieslistSelection.toggle(node)
        const found = this.selectedEntities.find(a => a.id === node.id)
        const canRemove = !!found
        if (canRemove) {
            this.selectedEntities = ArrayUtils.removeOneItem(this.selectedEntities, a => a.id === node.id)
            this.selectedEntities$.next(this.selectedEntities)
        }