multiselect shift on p:datatable

UI Components for JSF
tandraschko
PrimeFaces Core Developer
Posts: 3979
Joined: 03 Dec 2010, 14:11
Location: Bavaria, DE
Contact:

09 Jul 2011, 17:50

pe:datatable would be a merge hell, too^^ And yes, you are right oleg!
Thomas Andraschko

PrimeFaces | PrimeFaces Extensions

Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE

Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

10 Jul 2011, 13:46

merging each time would not necessarilly be a big problem. I just want it to be incorporated in the default datatable so it is not another jar to be downloaded etc...

Additional functionality: I have horizontal scrolling implemented as well now. I will create a container issue for all datatable related enhancements.

Cheers,

Ronald

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

10 Jul 2011, 15:36

ctrl-click is implemented for selectionmode='multiple', see http://primefaces.prime.com.tr/forum/vi ... =3&t=13190.

I think of adding a mode 'multiple-key', to have the current behaviour backwards compatible (although 3.0 is not released yet) options.

Shift-clicking is a bit more difficult. This is what I think multiple select with shift should behave like:
- If the item that is shift-clicked on is unselected, select all items in a datatable between it and the row that in the list of already selected rows is the closed to it but before it
- If the item that is shift-clicked on is selected, unselect all items in a datatable between it and the row that in the list of already selected rows is the furthest away in a contiguous group
But this can only be on the current page or over pages? PF uses row id's to select items and on a different page they are different from the page before, so you could do a 'click on row 1 on page 1 and shift-click on the last row on the last page and get all items in between selected

Agreed?

Ronald

btw labs showcase for datatable with multiple selection says:
Multiple selection is achieved by using modifier keys such as ctrl. Note that this example uses an ajax commandButton to
leftover from 2? ;-)

edit: added unselecting and confirming that row-id's are used over paging and they are different for pages.

User avatar
Oleg
Expert Member
Posts: 3805
Joined: 02 Oct 2009, 09:41
Location: Germany, Black Forest

10 Jul 2011, 17:19

Hi Ronald. Shift is a little bit difficult, but the algorithm is clear. Look any file managers - Windows Explorer, Dolphin in KDE or Nautilus in GNOME - they behave in a similar way for shift-selection.
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

10 Jul 2011, 17:29

Never used the KDE window manager, Gnome user myself, but I think the behaviour of Windows Explorer is not identical to Nautilus. The behaviour of nautilus is different from what I describe here and not intuitive. Try:
- select an item
- shift-click an item some below,
- ctrl-click an item further down,
- shift-click an item even furter down.

Expected: two contiguous blocks of selected items
Actual: one block where the last item of the original first block is the new start of this block.

I think windows explorer does what I 'expect' but maybe you can confirm (I do not have windows here)

User avatar
Oleg
Expert Member
Posts: 3805
Joined: 02 Oct 2009, 09:41
Location: Germany, Black Forest

10 Jul 2011, 18:29

Hi Ronald. Tried in KDE and had 2 block - expected behavior! I don't have Nautilus at the moment, but will try tomorrow Windows Explorer. I think Windows Explorer will get the same expected behavior.
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

11 Jul 2011, 11:57

Multi-select based on shift with getting two blocks is working... multi-unselect with shift not yet, but it is basically the reverse, so should not be to difficult.

One thing is the firering of select events. These are separate events, the real one that is clicked on fires first and then all the others. These are individual, not 'condensed' ajax calls, so if you select 100 rows, you currently get 100 ajax calls. Not efficient but that requires more changes on the java side, so I'll currently leave it as it is.

Question: what should the behaviour be if you click on a selected row in multi-select mode without a modifier key? My Nautilus just selects(!) that one row then, as does Windows Explorer

Oh, and in Nautilus I can get the two blocks if I shift-ctrl click as the last action... (so adding the ctrl instead of just the shift) and that is the same as in Windows Explorer (have a remote desktop at hand at work). The difference in Windows explorer is that if I do the second shift-click, so without the ctrl, it gives me one block where the start is the last one in the list that is selected. Now I think of it, this windows behaviour (how much I dislike windows) is the 'correct' behaviour. So if

["3", "4", "5", "9"] is selected and I select "11" with just shift, I get ["9", "10", "11"]. With shift-ctrl-click, I get ["3", "4", "5", "9", "10", "11"]

So the shift key is the modifier for 'select all between this and the one in the selected items that comes before this' and the ctrl key (on windows/linux, 'apple key' on mac, in javascript this is the 'metaKey') is the modifier for 'do this but add whatever you do to the previous selection)

wdyt?

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

11 Jul 2011, 12:01

another addition about the specs:

Both Nautilus and Windows Explorer with a shift click operate on the last selected item without a shift-click, not the one closest to it in the list of selected ones... So I'll change this behaviour accordingly

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

11 Jul 2011, 13:32

and what about events....

suppose ["1", "4", "5", "6"] is selected, where 4 was the last with ctrl-click and 5,6 are the result of a ctrl-shift-click and you ctrl-shift-click on 5, then 6 becomes unselected. Should that fire an unselect event and thus call an unselect event listener? I think it should.

And what if you do not ctrl-shift-click on 5, but shift-click on 5. Then 1 becomes unselected as wel, resulting in 2 unselect events (1 and 6).

User avatar
Oleg
Expert Member
Posts: 3805
Joined: 02 Oct 2009, 09:41
Location: Germany, Black Forest

11 Jul 2011, 14:22

Huh, it's getting more complicated. I can't follow your thoughts any more :-)
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 36 guests