Display datatable with auto selected checkbox

UI Components for JSF
Post Reply
Luuzz
Posts: 32
Joined: 28 Mar 2011, 15:21

06 Apr 2011, 18:36

Hello Primefaces Guys,
I have a datatable with check boxes in each row. On first display, i want some rows to be selected automatically. I tried using the selection attribute but apparently its value is never read It seems to be used for storing selected items after submit.
Is there a way to do so ?
Thanks in advance.
Primefaces 3.3 Jboss 7.1

healeyb
Posts: 365
Joined: 07 Apr 2010, 16:05

07 Apr 2011, 02:28

The value of the value= attribute of the component when it is rendered
is what will be initially displayed. If you have further questions don't
hesitate to ask.

Luuzz
Posts: 32
Joined: 28 Mar 2011, 15:21

07 Apr 2011, 11:40

I use the value attribute to get the datatable rows and they are all displayed.
But i want some of them to be checked on first display.
Primefaces 3.3 Jboss 7.1

CeeJay
Posts: 7
Joined: 22 Nov 2010, 20:31

07 Apr 2011, 12:04

im not sure if this is the answer you are loolink for, but i try to help.

Code: Select all

...
 <p:column styleClass="w30Center" sortBy="#{auftrag.checkvalue}">  
             <f:facet name="header">  
                 <h:outputText value="Some text:" />  
             </f:facet>  
             <h:selectBooleanCheckbox value="#{auftrag.checkvalue}" valueChangeListener="#{a_bean.valueChangeListener}"/>
  </p:column>
...
auftrag should be a class and checkvalue should have a getter and a setter from type boolen. the value of checkvalue you can modify in your code.

i hope this was helpfully

Luuzz
Posts: 32
Joined: 28 Mar 2011, 15:21

07 Apr 2011, 12:08

Fine I am going to try this.
Thank you
Primefaces 3.3 Jboss 7.1

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

07 Apr 2011, 12:56

If you populate your selection, the checkboxes corresponding to those rows will be checked on initial display. Make sure to override equals and hashcode.

http://www.primefaces.org/showcase/ui/d ... eckbox.jsf

Luuzz
Posts: 32
Joined: 28 Mar 2011, 15:21

08 Apr 2011, 11:53

Hello,
This is working great. I had overridden the equals method. My mistake was that the selection was declared as a collection and not an array.
Thank you all.
Primefaces rocks !!
Primefaces 3.3 Jboss 7.1

chinavictor
Posts: 5
Joined: 09 Jan 2011, 05:17

20 Jul 2011, 13:22

hello, could you share you code? i have the save problem, but couldn't fix it, please help me, thanks.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 45 guests