[英]Keep all row checkboxes & header row checkbox selected or checked by default in Angular-Slickgrid
I am using Angular SLickgrid and want to show all the checkboxes for all rows & also header row checkbox as selected by default (when grid loads).我正在使用 Angular SLickgrid 并希望显示所有行的所有复选框以及默认选中的 header 行复选框(当网格加载时)。 I am able to achieve it partly by using
this.angularGrid.gridService.setSelectedRows(this.allDataId)
but I am getting errors in console and all data rows are not visible.我可以通过使用
this.angularGrid.gridService.setSelectedRows(this.allDataId)
部分实现它,但我在控制台中遇到错误并且所有数据行都不可见。 I cannot use preset because I want to show all rows selected & till the time angular grid is loaded, I don't have all row IDs.我不能使用预设,因为我想显示所有选定的行,直到加载 angular 网格时,我没有所有行 ID。 Below is the error that I am getting.
下面是我得到的错误。 I have added null checks before passing data to
setSelectedRows()
but no use.在将数据传递给
setSelectedRows()
之前,我添加了 null 检查,但没有用。
TypeError: Cannot read property 'children' of null
at ensureCellNodesInRowsCache (dist/data.bundle.js.gz:2692)
at getCellNode (dist/data.bundle.js.gz:2692)
at updateCellCssStylesOnRenderedRows (dist/data.bundle.js.gz:2692)
at setCellCssStyles (/dist/data.bundle.js.gz:2692)
at Event.handleSelectedRangesChanged (/dist/data.bundle.js.gz:2692)
at Event.notify (/dist/data.bundle.js.gz:2674)
at RowSelectionModel.p [as setSelectedRanges] (/dist/data.bundle.js.gz:2692)
at SlickGrid.setSelectedRows (/dist/data.bundle.js.gz:2692)
at SlickGrid.m (/dist/data.bundle.js.gz:2692)
at Event.notify (/dist/data.bundle.js.gz:2674)
Please suggest how to achieve it.请建议如何实现它。 Thanks.
谢谢。
The answer, if that is an acceptable one, is in your question.答案,如果这是一个可以接受的答案,就在你的问题中。 The SlickGrid Row Selection plugin is not meant to be all selected at first so you have to stick with using
setSelectedRows
and if you don't have all Ids at hand then call it when you do... and in case you're pushing data in chunk, then call setSelectedRows
on each chunk. SlickGrid 行选择插件并不意味着一开始就被全部选中,所以你必须坚持使用
setSelectedRows
,如果你手头没有所有 Id,那么当你这样做时调用它......如果你正在推送数据在块中,然后在每个块上调用setSelectedRows
。 There's no magic here, you need to call it when you have the correct Ids这里没有魔法,当你有正确的 ID 时你需要调用它
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.