问题描述
我尝试使用以下方法访问该事件:
html
<ngx-datatable
class="margin-left bootstrap"
[rows]="rows"
[loadingIndicator]="'true'"
[rowHeight]="'30'"
[reorderable]="'true'"
[scrollbarH]="'true'"
[columnMode]="'standard'"
[columns]="columns"
[selectionType]="'checkBox'"
[selectAllRowsOnPage]="false"
(select)='onSelect($event)'>
</ngx-datatable>
但是该事件仅包含所选内容。除了最后单击的复选框,是否有办法取消所有选择?
解决方法
Swimlane提供了有关如何使用演示here清除所有选择here的示例。请注意页面顶部的“删除”按钮。
要点是利用@Inputs [selected]
和更新@Output (select)
。
component.html
<ngx-datatable
class="margin-left bootstrap"
[rows]="rows"
[loadingIndicator]="'true'"
[rowHeight]="'30'"
[reorderable]="'true'"
[scrollbarH]="'true'"
[columnMode]="'standard'"
[columns]="columns"
[selectionType]="'checkbox'"
[selectAllRowsOnPage]="false"
(select)='onSelect($event)'>
</ngx-datatable>
component.ts
export class MyComponent {
selected = [];
onSelect({ selected }) {
this.selected = [];
this.selected.push(...selected);
}
}