I adopted the code from this post and made this fiddle. Try clicking the first row, then shift-clicking the last row. If you notice this code does very well, except the last row, the row that you click on, does not get selected. I have been scratching my head on this one. Can anyone help me alter the code so that the multiselect selects the last row too?
Thanks!
I agree with Michael Gendin that you should not select the row with the id equal to
rowid
. It's your main error. Nevertheless I would rewrite the most code of the demo to use rowIndex of DOM elements of the rows instead of enumerating of all rows of the grid. Additionally the selection of the text in IE is uncomfortable in your current code, so I would suggest removing it. The modified demo which you find here I used the following code ofbeforeSelectRow
callback:try replacing this:
if ((shouldSelectRow = id == startID || shouldSelectRow)) {
with this:The solution of Oleg is not working in all selection mode (up/down). Thanks to him for the partial solution.
I correct this with this code:
You need 2 variables for stored the current start row Id and end row Id. And an other one to store the side of the selection.
Code call by the beforeSelectRow callback:
As discussed in Oleg's answer, here is an adjusted beforeSelectRow that does appended selections.
In my case, our users are selecting a bunch of rows for export, so additional selections does not usually mean they want to start a new selection.
Add
$('#grid').disableSelection();
to remove the annoying text selection