Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5979233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:37:50+00:00 2026-05-22T21:37:50+00:00

(See this question and this question for background…) Given: grid = new Slick.Grid(#myGrid, data,

  • 0

(See this question and this question for background…)

Given:

grid = new Slick.Grid("#myGrid", data, columns, options);
grid.setSelectionModel(new Slick.RowSelectionModel());
grid.onSelectedRowsChanged.subscribe(function() { 
   row_ids = grid.getSelectedRows();
   console.log(row_ids);
});

… when I select one row (say, row 5), I get an output of

[4]

… which is what I would expect. However, CMD+Click or SHIFT+Click -ing another row (say, row 3) in addition to this row gives me an output of

[2]
[4, 2]

… which is NOT what I would expect (I would expect just [4, 2]). This seems to happen so long as the number of rows selected is > 1. So, if I were to continue to select another row (say, row 17), I would get this

[16]
[4, 2, 16]

I added a breakpoint on the console.log statement and verified that the onSelectedRowsChanged is being fired twice: once for the newly clicked row, and once for all the selected rows.

Why is this? I only want it fired once, giving me the complete array of the selected rows. How would I accomplish this? Or am I missing something?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T21:37:51+00:00Added an answer on May 22, 2026 at 9:37 pm

    The problem (I’ve since discovered) lies in the row selection model Slick.RowSelectionModel().

    Specifically, when the row was selected, handleActiveCellChange() AND handleClick() were being called, each which calls setSelectedRanges(), while the former only sets it to the currently clicked row, and the latter sets it to all the selected rows.

    I fixed this by unregistering in init() (inside slick.rowSelectionModel.js) _grid.onActiveCellChanged handler and moved the call inside handleClick():

    function init(grid) {
       _options = $.extend(true, {}, _defaults, options);
       _grid = grid;
       // _grid.onActiveCellChanged.subscribe(handleActiveCellChange);
       _grid.onKeyDown.subscribe(handleKeyDown);
       _grid.onClick.subscribe(handleClick);
    }
    
    ...
    
    function handleClick(e, data) {
    
       ...
    
       if (!e.ctrlKey && !e.shiftKey && !e.metaKey) {
          handleActiveCellChange(e, data);
          return false;
       }
    
       ...
    
    }
    

    I don’t know if this has been fixed by the author in “v2 master”, as @fbuchinger said, and I know this fix is quick and dirty (this breaks keyboard navigation and selection between rows), but it works and gives me the expected behavior described in my question. Since I care more about the clicks working properly than the keyboard navigation, I’m sticking with this for now.

    Anyone know of a better way?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

See this previous question for some background. I'm trying to renumber a corrupted MPTT
Please see this question for background information: How do Tasks in the Task Parallel
As you can see this is a question from a non web developer. I
I see that over on this question LINQy way to check if any objects
This question is motivated by something I've lately started to see a bit too
Update: this question, including the title, was rephrased, see history for details I know
Duplicate of this question . update - This is not an exact duplicate. See
OK, so see questions like this one and this one and the question I
Please forgive me if this question is dense. Background: We have several internal applications
Please refer to this background question. After constructing this COUNT, how would I then

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.