Multiple selection ranges in Slick.CellSelectionModel

783 views
Skip to first unread message

Jérémy Clément

unread,
May 28, 2013, 4:33:33 AM5/28/13
to slic...@googlegroups.com
Hello, I would like to select more than one range (with Ctrl and Alt keys, same as Excel)

eg 2 selections : 
> selector.getSelectedRanges();
[ Range {
       fromRow=4, 
       fromCell=18, 
       toRow=4, 
       toCell=10
  } , 
  Range {
      fromRow=8, 
      fromCell=1, 
      toRow=10, 
      toCell=4
  }
]

Is it possible ?

Thanks

Michael Leibman

unread,
Jun 13, 2013, 2:27:09 PM6/13/13
to slickgrid
The API supports this, but the CellSelectionModel lacks this functionality right now.  This isn't trivial since it needs to be smart about recognizing when a new range that intersects with an existing one is added, and break them apart in multiple non-intersecting ones.  I'm open to contributions ;)


--
You received this message because you are subscribed to the Google Groups "SlickGrid" group.
To unsubscribe from this group and stop receiving emails from it, send an email to slickgrid+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Jérémy Clément

unread,
Jul 29, 2013, 11:03:21 AM7/29/13
to slic...@googlegroups.com
I implemented multiple selection, but only addition. A cell may be selected multiple times, it must be considered when using.
  • CTRL + CLICK: add to current cell selection
  • SHIFT + CLICK: adjusted current selection size
  • CTRL + DRAG: add selected cells to current selection
  • SHIFT + DRAG: add selected cells to current selection

TODO:
  • CTRL + CLICK / DRAG on selected cells: unselect
  • Merge selected ranges

I see two solutions for unselect:
  • split ranges around unselected cell
  • count the number of times the cell is selected: pair = unselected, odd = selected
it is not urgent for me, but I'll have to do. So I'll share
slick.cellselectionmodel.js

Jérémy Clément

unread,
Jul 29, 2013, 11:13:48 AM7/29/13
to slic...@googlegroups.com
oops, I forgot to remove some lines :

you have to delete this lines
line 81 :
function abortSelection() {
   _selector.abort();
}

line 200 :
"abortSelection" : abortSelection,

OR DOWNLOAD THE CORRECTED FILE IN THE ATTACHMENT

Le mardi 28 mai 2013 10:33:33 UTC+2, Jérémy Clément a écrit :
slick.cellselectionmodel.js

Jérémy Clément

unread,
Aug 29, 2013, 11:56:54 AM8/29/13
to slic...@googlegroups.com
NEW VERSION !

new : 
  • CTRL + CLICK / DRAG on selected cells: unselect
  • Merge selected ranges
fixed :
  • Cells can be selected one time only
todo :
  • some bugs with CTRL + arrow keys
  • algorithm optimization : reduce nested loops and group ranges for reduce size of response (actually : one range = one cell)

Le mardi 28 mai 2013 10:33:33 UTC+2, Jérémy Clément a écrit :
slick.cellselectionmodel.js
Reply all
Reply to author
Forward
0 new messages