简体   繁体   中英

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). 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. 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. Below is the error that I am getting. I have added null checks before passing data to setSelectedRows() but no use.

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. There's no magic here, you need to call it when you have the correct Ids

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM