2
votes

I have a PrimeFaces DataTable with one column, called 'name' and a rowexpansion with the 'description'.

Is it possible, to make these rows selectable by clicking, but at expansion the selecting event can not be fired?

EDIT

<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>
1
If the dataTable has selection enabled, the expansion is not displayed at all. Not sure if this is by design or not.perissf
@perissf updated my question with code sample. this works, when i click the expanding icon, it expands the row, but also opens the dialog. i want to only show the dialog, when the user click on the name column.krstf

1 Answers

0
votes

Instead of making the entire column open the dialog, you can update the outputText within the column to a commandLink, which will still use AJAX to make a call to the backing bean:

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