Use selectionMode as "single" and "multiple" for same table

UI Components for JSF
mitnpatel
Posts: 23
Joined: 05 Mar 2011, 04:47
Location: San Jose

23 Jun 2011, 18:31

Hi,

I have requirement to use single selection and multiple selection on same table.
I have one table on left hand side of page and depending upon users selection (single row selection or multiple row selection) I need to update right hand side of page.
If user select just one row then I have to display view A and if user select multiple rows (more than one) then I have to display view B.

I know that in primefaces table i can have single selection or multiple slecetion mode on table but as per my requirement i have to combine both of same table.

Any idea how this can be achived ?

Thanks
Primeface 3.2 | Tomcat 7.0.21 | MyFaces 2.1.5 | Eclipse 3.7 | CentOs 5.6

robert.m
Posts: 226
Joined: 07 Dec 2010, 22:52
Location: Salzburg/Austria

23 Jun 2011, 20:11

I never really used the selection-feature of the datatable. but you could use multiple-selection and check if the number of selected rows is 1 or more and act accordingly.
would that be an option?

mitnpatel
Posts: 23
Joined: 05 Mar 2011, 04:47
Location: San Jose

23 Jun 2011, 21:02

I am currently doing that but the problem with this aproch is :

When user selecet 10 rows and then he wants to select only one row then in order to do that he need to "Unselect" other remaining 9 rows first.

So form useablility prospective it not user firendly.
Primeface 3.2 | Tomcat 7.0.21 | MyFaces 2.1.5 | Eclipse 3.7 | CentOs 5.6

mitnpatel
Posts: 23
Joined: 05 Mar 2011, 04:47
Location: San Jose

30 Jun 2011, 00:26

No thoughts about how to achive this ?
Primeface 3.2 | Tomcat 7.0.21 | MyFaces 2.1.5 | Eclipse 3.7 | CentOs 5.6

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

08 Jul 2011, 10:27


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

08 Jul 2011, 10:58

Hi mitnpatel,

I didn't totally understand why you need "single selection and multiple selection on same table". Try with multi-selection. If user selected one row - view A, if more - view B. The check is easy done if you process the table or use instant row selection. What is the problem?
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

08 Jul 2011, 13:09

Oleg, see my reply in the post I mentioned above. I describe the reason for this.

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

08 Jul 2011, 14:00

There is no built-in way, it is either one or the other unless you hack/extend it somehow.

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

08 Jul 2011, 14:29

optimus.prime wrote: unless you hack/extend it somehow.
Trying just that (in combination with shift-click), but new to jquery internals, so it might take a while (up to just before 3.0 GA e.g. :-))

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

08 Jul 2011, 16:03

Ok, I see. I have done this quite simple and user-friendly in one of my web applications (no PrimeFaces, Struts and my own table implementation). My proved approach is:

1) Selection is done either by checkboxes or row click.
2) By checkboxes you can select multiply rows. Rows are also highlighted.
3) By click on a row all previous selected rows get deselected. This is a single selection then.

See screenshots

Multi-Selection

Image

Single-Selection (the same table)

Image

Edit: And my context menu on a table (right mouse click) is aware of selected rows and is built up dynamically on the client-side only :-) I'm missing that all in PrimeFaces, so that some hacks are needed in the future.
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 53 guests