treeControl = new FlatTreeControl<any>(
node => node.level,
node => node.expandable
);
treeFlattener = new NzTreeFlattener(
this.transformer,
node => node.level,
node => node.expandable,
node => node.children
);
dataSource = new NzTreeFlatDataSource(this.treeControl, this.treeFlattener);
hasChild = (_: number, node: any): boolean => node.expandable;
ngOnChanges(changes: SimpleChanges) {
this.dataSource.setData(orderList.currentValue);}
updateTreeNode() {
this.orderList.forEach((item: any) => {
if (item.itemList) {
item.itemList.forEach((i: any) => {
i.key = item.key;
i.isItem = true;
i.isCheck = false;
i.partId = i.defaultPartId;
i.strengthId = i.defaultStrengthId;
i.defaultItemId = i.itemId;
});
}
item.children = item.itemList;
});
console.log('传入的orderList', this.orderList);
this.dataSource.setData([...this.orderList]);
console.log('dataSource', this.dataSource.getData());
console.log('dataNodes', this.treeControl.dataNodes);
this.cd.markForCheck();
}
我初始化树的时候,先将传入的orderList赋值给dataSource,然后我改变了这个orderList的时候,需要修改树视图的dataSource的值,和orderList同步数据,问题是dataSource的_data的值改变了,但treeControl.dataNodes的值还是初始化的值,怎么改变都无效,改怎么做