【发布时间】:2018-05-15 20:00:35
【问题描述】:
我正在尝试在 PrimeNG 树中设置选定的项目。
HTML
<p-tree id="selectedProducts" *ngIf="selectedCustomer != null"
[value]="tree" selectionMode="checkbox"
[(selection)]="selectedProducts"
(click)="fileterProducts()"></p-tree>
TS
selectedProducts: TreeNode[] = [];
filteredProducts: number[] = [];
tree: TreeNode[] = [];
selectCustomer(customerId: number){
this.selectedCustomer = this.selectedCustomers.find(r => r.Name == this.userForm.value.Customers[0]);
console.log("Customer Products ");
console.log(this.selectedCustomer.selectedProducts);
this.selectedProducts = this.selectedCustomer.selectedProducts;
for ( let product of this.selectedProducts ) {
product.expanded = true;
this.expandChildren(product);
console.log('Product : ');
console.log(product);
}
我把所有节点都展开了,但它似乎没有被选中。
【问题讨论】:
-
你能分享你的组件TS代码吗?
-
我在上面添加了代码
-
但它似乎没有被选中 你的意思是复选框没有被选中或者叶子没有被展开?你能创建一个 StackBlitz 吗?
标签: angular primeng primeng-treetable