在 html 元素选择上设置数据源时,复选框的主切换不起作用 [英] Master toggle for checkbox not working when datasource is set on html element selection
问题描述
我有一个类似的问题 -
I have a similar issue like of the question -
复选框的主切换不在多个扩展的 Mat-Table 行中工作 .
但不是 this.usersdataSource[element.Id] = new MatTableDataSource(res);
在那里使用,我将它用作 element['usersdataSource'] = new MatTableDataSource(res));
But instead of this.usersdataSource[element.Id] = new MatTableDataSource(res);
used there , I have used it as element['usersdataSource'] = new MatTableDataSource(res);
现在在解决方案中我看到使用了 selectionMap -
Now in the solution i see that selectionMap is used -
userSelectionMap: Map<number, SelectionModel<any>> = new Map<number,SelectionModel<any>>();
UserMasterToggle(elementId: number) {
this.isAllUserSelected(elementId)
? this.userSelectionMap.get(elementId).clear()
: this.usersdataSource[elementId].data.forEach(row =>
this.userSelectionMap.get(elementId).select(row)
);
}
isAllUserSSelected() {
const numSelected = this.userSSelection.selected.length;
const numRows = this.leftPanelDataSource.data.length;
return numSelected == numRows;
}
我应该如何使用 userSelectionMap: Map
当我将数据源值分配给元素值时,如 element['usersdataSource'] = new MatTableDataSource(res);
How should i use userSelectionMap: Map<number, SelectionModel<any>> = new Map<number,SelectionModel<any>>();
when i have assigned datasource value to the element value like element['usersdataSource'] = new MatTableDataSource(res);
我有针对我的问题的有效 stackblitz 链接 - 任何人都可以帮忙
I have working stackblitz link for my issue - can anyone please help
谢谢
推荐答案
这里有一个 解决了您的问题的有效 stackblitz 链接.
这篇关于在 html 元素选择上设置数据源时,复选框的主切换不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!