简体   繁体   English

具有多行选择的primefaces数据表

[英]primefaces datatable with multiple row selection

I want to select multiple rows from a primefaces datatable, i followed the examples in the showcase , but no results 我想从primefaces数据表中选择多行,我按照展示中的示例进行操作,但是没有结果

here is my XHTML: 这是我的XHTML:

<p:dataTable id="tabJob" var="contenuJob" value="#{templateBean.contenuJob}" selection="#{templateBean.selectedRows}" 
rowKey="#{templateBean.idJob}" style="margin-bottom:0"
scrollable="true" scrollHeight="250" rowIndexVar="rowIndex" >

                        <p:column selectionMode="multiple" style="width:16px;text-align:center" />
                 <f:facet name="header">  
                    selectionner les colonnes
                  </f:facet>  

                <p:column headerText="#" style="width:3%"> #{rowIndex+1}</p:column>
                <p:columns value="#{templateBean.colonnes}" var="colonnes" columnIndexVar="ind" id="col#{ind}">
                        <f:facet name="header">
                              <h:outputText value="#{colonnes}"/>
                        </f:facet>#{contenuJob[ind]}
                </p:columns>

                <f:facet name="footer">  
                    <p:commandButton process="tabJob" value="valider"    action="#{templateBean.validerSelection()}"/>  
                </f:facet>  

        </p:dataTable> 

and in my ManagedBean: 在我的ManagedBean中:

private ArrayList<String> contenuJob,selectedRows;
.................
public String validerSelection(){


        System.out.println("size de selectedRows ::"+selectedRows.size());

        return null;
    }

and the sop only returns 1 which is the size, i've already tried rowSelectMode="add" in the datatable but it didn't change a thing 并且sop仅返回1,即大小,我已经在数据表中尝试过rowSelectMode =“ add”,但它没有改变任何东西

正如Jaqen H'ghar所说 ,我更改为rowKey="#{contenuJob}" ,它的工作非常完美:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM