GridStateService always clear row selections even though syncGridSelection is TRUE
See original GitHub issueI’m submitting a Bug report
Your Environment
Software | Version(s) |
---|---|
Angular | 8 |
Angular-Slickgrid | 2.x |
Context
this.gridOptions = {
enableFiltering: true,
enableGrouping : true,
enableCheckboxSelector: true,
enableCellNavigation : false,
dataView : {syncGridSelection : true}
};
Setting syncGridSelection to TRUE does not preserve the row selections whenever I change the column filter. See #191
Expected Behavior
It should preserve the row selections if syncGridSelection is TRUE
Possible Solution
Probably can consider changing gridState.service.ts to something like below:
// Check whether the row selection needs to be preserved
private needToPreserveRowSelection(): boolean {
let preservedRowSelection = false;
if (this._gridOptions && this._gridOptions.dataView && this._gridOptions.dataView.hasOwnProperty('syncGridSelection')) {
const syncGridSelection = this._gridOptions.dataView.syncGridSelection;
if (typeof syncGridSelection === 'boolean') {
preservedRowSelection = <boolean>this._gridOptions.dataView.syncGridSelection;
} else {
preservedRowSelection = syncGridSelection.preserveHidden;
}
}
return preservedRowSelection;
}
/** if we use Row Selection or the Checkbox Selector, we need to reset any selection */
resetRowSelection() {
if (this._gridOptions.enableRowSelection || this._gridOptions.enableCheckboxSelector) {
// this also requires the Row Selection Model to be registered as well
const rowSelectionExtension = this.extensionService && this.extensionService.getExtensionByName && this.extensionService.getExtensionByName(ExtensionName.rowSelection);
if (!this.needToPreserveRowSelection() && rowSelectionExtension && rowSelectionExtension.instance) {
this._grid.setSelectedRows([]);
}
}
}
Code Sample
Issue Analytics
- State:
- Created 4 years ago
- Comments:20 (20 by maintainers)
Top Results From Across the Web
GridStateService always clear row selections even though ...
Setting syncGridSelection to TRUE does not preserve the row selections whenever I change the column filter. See #191 ...
Read more >SlickGrid DataView syncGridSelection does not remove the ...
So it looks like the selection is still there when in fact it's been removed, but that row is now active. Just delete...
Read more >Slickgrid Dataview Syncgridselection Does Not ... - ADocLib
Slickgrid Dataview Syncgridselection Does Not Remove The Old Selection When The Table Changes ... GridStateService always clear row selections even though ...
Read more >angular-slickgrid - UNPKG
getLength();\r\n\r\n // loop through all the grid rows of data\r\n for (let ... }\n\n // filter search terms should always be string type...
Read more >Which class does a selected row use? Row ... - Google Groups
Row selection implemented through RowSelectionModel. 1428 views ... But, the row color doesn't change (not even to the beige color used in the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I confirm that it’s working perfectly now, thank you!
Point taken, I’m not very familiar with your code, but I was doing my best to be helpful by giving instructions to reproduce the problem. I’ll try to make more of a contribution next time.
@timhawkins1 Another morning spent on this… it should be fixed now, you can test it in Example 12 where I added the row selection and some more Cypress E2E tests.
I have to say though that next time around I’d like to get a bit more help in troubleshooting and/or testing, even just adding some Cypress E2E tests would have been helpful. This is an Open Source project for a reason, I’d like to have contributions once in a while (at least that was the reason of why we decided to make it Open Source).