【问题标题】:PrimeFaces expandable and selectable rowPrimeFaces 可扩展和可选行
【发布时间】:2012-11-10 20:54:37
【问题描述】:

我有一个 PrimeFaces 数据表,其中有一列称为“名称”,还有一个带有“描述”的行扩展。

是否可以通过单击使这些行可选择,但在展开时无法触发选择事件?

编辑

<h:form id="customerCategoryListForm">
    <p:dataTable var="customerCategory" value="#{admin.customerCategories}" id="customerCategoryList" 
        paginator="true" rows="10" 
        rowKey="#{customerCategory.id}" selectionMode="single" selection="#{admin.selectedCustomerCategory}"
        paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
        rowsPerPageTemplate="10,25,50"
        emptyMessage="Nincs adat!">
        <p:ajax event="rowSelect" update=":customerCategoryDialogForm:customerCategoryDisplay" oncomplete="customerCategoryDialog.show()" />  

        <f:facet name="header">  
            Categories
        </f:facet>

        <p:column width="10">
            <p:rowToggler />
        </p:column>

        <p:column headerText="Category name" sortBy="#{customerCategory.name}" width="740">
            <h:outputText value="#{customerCategory.name}" />
        </p:column>

        <p:rowExpansion>
            <h:outputText value="#{customerCategory.description}" />
        </p:rowExpansion>

        <f:facet name="footer">
            <p:commandButton value="Új hozzáadása" />
        </f:facet>

    </p:dataTable> 
</h:form>

【问题讨论】:

  • 如果dataTable开启了选择,则完全不显示展开。不确定这是否是设计使然。
  • @perissf 用代码示例更新了我的问题。这有效,当我单击扩展图标时,它会扩展行,但也会打开对话框。我只想在用户单击名称列时显示对话框。

标签: jsf-2 primefaces


【解决方案1】:

您可以将列中的 outputText 更新为 commandLink,而不是让整个列打开对话框,这仍将使用 AJAX 来调用支持 bean:

<p:commandLink value="#{customerCategory.description}" actionListener="#{customerCategory.fooMethod(customerCategory)}" update=":customerCategoryDialogForm" oncomplete="PF('customerCategoryDialog').show();"/>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-19
    • 1970-01-01
    • 2012-05-03
    • 2013-04-02
    • 2016-05-28
    • 2017-10-21
    相关资源
    最近更新 更多