Page 1 of 1

datatable selection

Posted: 01 Jul 2010, 12:32
by knylmz
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>

Re: datatable selection

Posted: 01 Jul 2010, 13:04
by mouadh
to get the multiple selection work, selectedAuthories must be an array :
Authories[] selectedAuthories;

Re: datatable selection

Posted: 08 Jul 2010, 22:00
by knylmz
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.

Re: datatable selection

Posted: 09 Jul 2010, 09:14
by michiel
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>

Re: datatable selection

Posted: 09 Jul 2010, 09:20
by Daedalus
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

Re: datatable selection

Posted: 09 Jul 2010, 11:18
by cagatay.civici
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.