question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

GridStateService always clear row selections even though syncGridSelection is TRUE

See original GitHub issue

I’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:closed
  • Created 4 years ago
  • Comments:20 (20 by maintainers)

github_iconTop GitHub Comments

1reaction
timhawkins1commented, Feb 7, 2020

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.

0reactions
ghiscodingcommented, Feb 6, 2020

@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).

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found