import { TreeTableComponent } from '@farris/ui-treetable'; import { Component, OnInit, ViewChild, ViewEncapsulation } from '@angular/core'; import { data as treeData } from '../../treetable-demo.data'; import { isThisISOWeek } from 'date-fns'; import { of } from 'rxjs'; @Component({ selector: 'demo-cascadeCheck', templateUrl: './demo-cascade-check.component.html', styles: [ ` .farris-treetable-nowrap .farris-treetable-tbody td { word-break: break-all; white-space: break-spaces; } ` ], encapsulation: ViewEncapsulation.None }) export class DemoCascadeCheckComponent implements OnInit { treedata = treeData.data; cols = []; multiSelect = true; showCheckAll = true; showCheckbox = true; cascadeCheck = false; cascadeDown = false; cascadeUp = false; checkOnSelect = false; selectOnCheck = false; onlySelectSelf = false; keepSelect = false; headerWrap = false; nowrap = true; checkedValues = 'Desktop,Travel,Downloads,Expenses.doc,Documents,222'.split(','); selectedValues = []; selectedValue = null; @ViewChild('tt') tt: TreeTableComponent; constructor() { } ngOnInit() { this.cols = [ { field: 'name', title: '超长的标题哦会不会折行哦,哈哈', width: 200, sortable: true}, { field: 'size', title: 'Size', width: 100 }, { field: 'type', title: 'Type', width: 100}, { field: 'single', title: '单身', width: 100}, { field: 'age', title: '年龄', width: 100}, { field: 'birthday', title: '日期', width: 100}, { field: 'photo', title: '头像', width: 100}, { field: 'xueli', title: '学历', width: 100} ]; } checkNodes() { const nodeIDs = 'Desktop,Travel,Downloads,Expenses.doc,Documents'; this.tt.checkedNodes(nodeIDs.split(',')); } checkNodesWithProperty() { const nodeIDs = 'Desktop,Travel,Downloads,Expenses.doc,Documents'; this.checkedValues = nodeIDs.split(','); } getCheckedNodes() { console.log('Checkeds:', this.tt.checkeds, this.checkedValues); } getSelectedNodes() { console.log('Selections:', this.tt.selections, this.selectedValues); } selectNodesWithProperty() { const nodeIDs = 'Desktop,Travel,Downloads,Expenses.doc,Documents'; this.selectedValues = nodeIDs.split(','); } clearAll() { this.tt.clearAll(); } onNodeSelected($event) { console.log($event); } onBeforeClickNode = (e) => { console.log(e); return of(true); } onBeforeCheckAll = (e) => { console.log(e); return of(true); } onBeforeUnCheckAll = (e) => { console.log(e); return of(true); } selectNodeById() { const id = prompt('选中行ID'); if (id !== '') { this.tt.selectNode(id); } } }