4

This is a clumsy question!!! :)

Can this be made possible somehow? Can <p:dataTable> (whatever lazily loaded or otherwise) be updated without updating its headers (The contents (rows) inside the table along with the footer should be updated without updating the table headers)?

Updating of <p:dataTable> may be triggered by any UICommand like <p:commandButton>, <p:commandLink> and alike.

Something like this can be visualized, when we edit/update rows using <p:cellEditor> in conjunction with <p:rowEditor/> in <p:dataTable> (not sure about single cell editing).

<p:dataTable id="dataTable" var="row" value="#{bean}" ...>
    <p:column headerText="Header 1" sortBy="#{row.property1}" filterBy="#{row.property1}">
        ....
    </p:column>
    <p:column>
        <!--They may be our own headers-->
        <f:facet name="header">
            Header 2
            ...
        </f:facet>
        ....
    </p:column>
    ...
</p:dataTable>
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Tiny
  • 27,221
  • 105
  • 339
  • 599

1 Answers1

8

Easiest way is to use PrimeFaces Selectors (PFS) for this. This only requires the desired cell content being wrapped in another component with an ID and a style class — so that jQuery can find and collect them.

E.g.

<p:dataTable ...>
    <p:column>
        <f:facet name="header">...</f:facet>
        <h:panelGroup id="col1" styleClass="cell">...</h:panelGroup>
    </p:column> 
    <p:column>
        <f:facet name="header">...</f:facet>
        <h:panelGroup id="col2" styleClass="cell">...</h:panelGroup>
    </p:column> 
    <p:column>
        <f:facet name="header">...</f:facet>
        <h:panelGroup id="col3" styleClass="cell">...</h:panelGroup>
    </p:column> 
    ...
</p:dataTable>
<p:commandButton value="update" update="@(.cell)" />

That wrapping is clumsy, yes, but that's best you can get without homebrewing a custom renderer. You can always create a <my:column> tagfile to reduce the boilerplate.

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • I still cannot just visualize in case, for example, `...` inside `` is to be skipped from being updated, when `` itself is updated. – Tiny Nov 28 '13 at 20:19
  • Not sure what you mean, but `` should of course go outside the panel groups. I've clarified the answer. – BalusC Nov 29 '13 at 11:15
  • This wrapping is indeed **not** clumsy now. :) Thanks. – Tiny Nov 29 '13 at 20:23