1

嗨,我有一个带有延迟数据加载的数据表和一个带有选择/取消选择所有项目选项的上下文菜单。但我不知道怎么做。

<h:form>
    <p:contextMenu for="tableNozzleFamily">  
        <p:menuitem value="#{bundle.global_select_all}" icon="ui-icon-plus"/>
        <p:menuitem value="#{bundle.global_unselect_all}" icon="ui-icon-minus"/>
    </p:contextMenu> 
    <p:dataTable id="tableNozzleFamily" var="nf" value="#{nozzleBean.lazyModel}" paginator="true" rows="20" rowsPerPageTemplate="20, 30, 50" lazy="true" emptyMessage="#{bundle.global_no_data}" selection="#{nozzleBean.selectedNozzleFamilies}">
        <p:columnGroup type="header">
            <p:row>
                <p:column rowspan="2" headerText="#{bundle.global_selection}"/>
                 ...
            </p:row>
        </p:columnGroup>
        <p:column selectionMode="multiple" style="width:18px"/>
        ...
    </p:dataTable>

我的环境:Glassfish 3.1.2.2 Mojarra-2.1.11 Primefaces-3.3.1

4

1 回答 1

3

你检查过primefaces展示吗?有一个例子就是这样做

<p:dataTable id="multiCars" var="car" value="#{tableBean.mediumCarsModel}" paginator="true" rows="10"  
             selection="#{tableBean.selectedCars}">  

    <f:facet name="header">  
        Checkbox Based Selection  
    </f:facet>  

    <p:column selectionMode="multiple" style="width:18px" />  

    <p:column headerText="Model">  
        #{car.model}  
    </p:column>  

    <p:column headerText="Year">  
        #{car.year}  
    </p:column>  

    <p:column headerText="Manufacturer" >  
        #{car.manufacturer}  
    </p:column>  

    <p:column headerText="Color">  
        #{car.color}  
    </p:column>  

    <f:facet name="footer">  
        <p:commandButton id="multiViewButton" value="View" icon="ui-icon-search"  
                         update=":form:displayMulti" oncomplete="multiCarDialog.show()"/>  
    </f:facet>  
</p:dataTable>
于 2012-08-06T12:20:15.477 回答