Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent useless onSelectedRangesChanged events in selectionmodels' setSelectedRanges #9

Closed
evil-shrike opened this issue May 29, 2015 · 0 comments

Comments

@evil-shrike
Copy link

Plugins slick.cellselectionmodel and slick.rowselectionmodel have function setSelectedRanges which sets selected range and fires onSelectedRangesChanged event.
Unfortunately the event is fired in any case even if range didn't change. As consequence grid fires onSelectedRowsChanged event.
That can (and does) have some useless processing.
For example slick.checkboxselectcolumn plugin in its handleSelectedRowsChanged updates column header.

    function setSelectedRanges(ranges) {
      _ranges = ranges;
      _self.onSelectedRangesChanged.notify(_ranges);
    }

I suggest to put a simple check for empty range:

    function setSelectedRanges(ranges) {
      // simle check for: empty selection didn't change, prevent firing onSelectedRangesChanged
      if ((!_ranges || _ranges.length === 0) && (!ranges || ranges.length === 0)) { return; }
      _ranges = ranges;
      _self.onSelectedRangesChanged.notify(_ranges);
    }
@evil-shrike evil-shrike changed the title Prevent excessive onSelectedRangesChanged events on Prevent useless onSelectedRangesChanged events in selectionmodels' setSelectedRanges May 29, 2015
evil-shrike pushed a commit to croc-code/SlickGrid that referenced this issue May 29, 2015
@6pac 6pac closed this as completed Jun 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants