由网友(隐退的王)分享简介:是否可以使用一个按钮远程清除多选(或多选)?我正在对turbo表使用Primeng多选我已经看过此问题几次,但没有选择答案。下面是我的多选:
![雷诺发布全新1.6升双涡轮增压发动机](https://p.xsw88.cn/allimgs/daicuo/20230904/56.png)
我已经看过此问题几次,但没有选择答案。
下面是我的多选:
<span *ngIf="col.field == 'Product'">
<p-multiSelect [options]="getUniques(col.field)"
(onChange)="dt.filter($event.value, col.field, 'in')">
</p-multiSelect>
</span>
![雷诺发布全新1.6升双涡轮增压发动机](https://p.xsw88.cn/allimgs/daicuo/20230904/56.png)
这是我的按钮:
<p-button label="Clear All"
styleClass="ui-button-primary"
(click)="onResetAll($event, dt)">
</p-button>
以下是我尝试重置值但似乎没有重置的方法:
onResetAll(event, dt) {
dt.filter('', 'Product', 'contains');
}
推荐答案
下面的多选
第一个集视图子选择器#cmp
<p-multiSelect #cmp [options]="cars" appendTo="body"
(onChange)="table.filter($event.value, 'brand', 'in')">
</p-multiSelect>
在组件的声明集后面的代码中
@ViewChildren('cmp') components: QueryList<MultiSelect>;
并更新您的按钮单击事件
onResetAll(event, dt) {
this.components['_results'].forEach(ds => {
ds.value = null;
ds.updateLabel();
});
dt.filter('', 'brand', 'contains');
}
演示here
相关推荐
最新文章