datatable selection

Components, Ajax Framework, Utilities and More.
Post Reply
knylmz
Posts: 2
Joined: 20 Feb 2010, 20:34

01 Jul 2010, 12:32

hi dear primefaces users,
i want to use primefaces's datatable for my role's authoies. My update page is show role and its authories. All autroies is listed data table and my role's authoies must be selected. following codes do not work in my scope.

Code: Select all

<p:dataTable id="authories" var="authory"  value="#{roleController.authories}" 
					rows="10" paginator="true"
 					selection="#{roleController.selectedAuthories}" selectionMode="multiple"
					>
			<p:column>
				<f:facet name="header">
					<h:outputText value="Authory Name" />
				</f:facet>
				<h:outputText value="#{authory.name}"></h:outputText>
			</p:column>
</p:dataTable>

User avatar
mouadh
Posts: 85
Joined: 27 Apr 2010, 12:47
Location: Tunisia

01 Jul 2010, 13:04

to get the multiple selection work, selectedAuthories must be an array :
Authories[] selectedAuthories;
Ben Khalifa Mouadh
engineering student at National School of Computer Sciences - Tunisia
JSF 2.0, GlassFish v3, PF 2.0.1,Majorra 2.0.2, netBeans 6.8

knylmz
Posts: 2
Joined: 20 Feb 2010, 20:34

08 Jul 2010, 22:00

hi,
İ want to do this:
before my page is opened, my authories of role had been selected in roleManagement page. but it doesnt work so.

User avatar
michiel
Posts: 240
Joined: 07 Jun 2010, 09:12
Location: Belgium

09 Jul 2010, 09:14

Datatable preselection is not implemented (at least for now)

you can "solve" it by using instead of the selection an extra column with checkboxes,
something like:

Code: Select all

<p:dataTable id="authories" var="authory"  value="#{roleController.authories}" rows="10" paginator="true">
         <p:column>
            <f:facet name="header">
               <h:outputText value="inRole" />
            </f:facet>
            <h:selectBooleanCheckbox id="openDossiers" value="#{authory.inRole}">
               <p:ajax event="click" update="authories"/>
            </h:selectBooleanCheckbox>
         </p:column>
         <p:column>
            <f:facet name="header">
               <h:outputText value="Authory Name" />
            </f:facet>
            <h:outputText value="#{authory.name}"></h:outputText>
         </p:column>
</p:dataTable>
JSF-2.0, mojarra-2.0.2-FCS and PrimeFaces-2.1 on GlassFish v3.0.1 (build 22)

User avatar
Daedalus
Posts: 164
Joined: 28 Jan 2010, 12:03

09 Jul 2010, 09:20

Also you could use JavaScript.

Your DataTable needs a widgetVar. For example:

<p:dataTable widgetVar="yourTable" .... >


Use this JavaScript

yourTable.selectRow(1); //selects row 1
yourTable.selectRow(2); //selects row 2 too
yourTable.selectRow(3); //selects row 3 too
PrimeFaces 3.0, Glassfish 3.1.2, Mojarra 2.1.6,

User avatar
optimus.prime
Prime
Posts: 17586
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

09 Jul 2010, 11:18

Datatable preselection was implemented if it doesn't work please create an issue. We're pushing all datatable related issues to 2.1.1 as it will introduce new powerful datatable soon.

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 6 guests