Possible bug in "select" extension?

Possible bug in "select" extension?

dmcglynndmcglynn Posts: 15Questions: 5Answers: 0

I am using a jquery-selector to limit row-selection, and it works correctly, except that if someone holds shift to select multiple rows, they can 'include' the undesired row in their selection, and it will select.

So, I attempted to get around this by starting to use the select event, to manually remove that row from the selection-set. I copied the example from the documentation, but I ran into the following strange results:

Selecting from the TOP to BOTTOM, it selects all three rows, while selecting from the BOTTOM to TOP, it seems to not select the undesired row.

https://jsfiddle.net/t09qcvd4/15/

If you comment out line #12, the behavior changes, back to the original where selection can occur both ways, though this line should have no effect on anything, as it's simply pulling data out of the table.

Anyone have any ideas?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,322Questions: 1Answers: 10,023 Site admin
    Answer ✓

    Interesting one! So the problem with the original setup just using the selector is that the selector is used only for the click event. It is not used for rows in between since the event didn't occur on those rows and there would be know way to know what the user's intention was (in this case its fairly limited since its on the whole row, but for cases when an element inside a cell, such as a checkbox, is used, it would be horribly complicated).

    I think your use of select is probably the way to go here. Combine it with a check on the row's class and if it shouldn't be selected immediately deselect it: https://jsfiddle.net/t09qcvd4/16/ .

    Allan

  • dmcglynndmcglynn Posts: 15Questions: 5Answers: 0

    Thanks Allan, I hadn't yet got to that part, but I'm sure your solution is much more concise than mine would have been!

    My problem is solved, but I thought it was strange that you could select if you went TOP to BOTTOM, but not BOTTOM to TOP. And if you don't get the ID on line 12, it changed the behavior.

    Thanks so much for the quick response. Your software is fantastic!

  • allanallan Posts: 61,322Questions: 1Answers: 10,023 Site admin

    That is weird, and I wasn't actually able to recreate it (Chrome /Linux), so I must confess I forgot to reply to that point.

    The top / bottom and bottom / top behaviour should really be identical.

    Allan

This discussion has been closed.