0

The rendering of a search mask works with ui:repeat but not with p:dataTable. Can someone explain this?

Working:

<p:panelGrid>
    <ui:repeat value="#{curSearch.getSearchMaskDescription().getRows()}" var="curRow" varStatus="rowStatus">
        <p:row >
            <ui:repeat value="#{curRow.getElements()}" var="curMaskElement" varStatus="colStatus">
                <p:column colspan="#{curMaskElement.columnSpan}">

                    <mycomp:searchFieldCC isShortSearchMask="false" curMaskElement="#{curMaskElement}" curRowIndex="#{rowIndexVar}"
                        curColumnIndex="#{columnIndexVar}" />

                </p:column>
            </ui:repeat>
        </p:row>
    </ui:repeat>
</p:panelGrid>

Not working:

<p:dataTable id="searchMaskTableId" value="#{curSearch.getSearchMaskDescription().getRows()}" var="curRow" rowIndexVar="rowIndexVar"
    styleClass="searchMaskFieldsGrid">
    <p:columns value="#{curRow.getElements()}" var="curMaskElement" columnIndexVar="columnIndexVar" colspan="#{curMaskElement.columnSpan}">

        <mycomp:searchFieldCC isShortSearchMask="false" curMaskElement="#{curMaskElement}" curRowIndex="#{rowIndexVar}" curColumnIndex="#{columnIndexVar}" />

    </p:columns>
</p:dataTable>

The difference is only the iteration I think. ui:repeat is built in another phase, but I had expected that the ui:repeat does not work instead. The rendered html with p:dataTable:

<div id="searchInstancesFormId:searchMaskTableId" class="ui-datatable ui-widget searchMaskFieldsGrid">
    <div class="ui-datatable-tablewrapper">
        <table role="grid">
            <thead id="searchInstancesFormId:searchMaskTableId_head">
                <tr role="row"></tr>
            </thead>
            <tbody id="searchInstancesFormId:searchMaskTableId_data" class="ui-datatable-data ui-widget-content">
                <tr data-ri="0" class="ui-widget-content ui-datatable-even" role="row"></tr>
                <tr data-ri="1" class="ui-widget-content ui-datatable-odd" role="row"></tr>
                <tr data-ri="2" class="ui-widget-content ui-datatable-even" role="row"></tr>
                <tr data-ri="3" class="ui-widget-content ui-datatable-odd" role="row"></tr>
                <tr data-ri="4" class="ui-widget-content ui-datatable-even" role="row"></tr>
            </tbody>
        </table>
    </div>
</div>

There are not columns rendered. Why? The form is updated via ajax. The data model is correct.

opfau
  • 731
  • 9
  • 37
  • 1
    Wrong usage (as do many) of the columns tags. You cannot create columns for individual rows (what if they have a different number of columns). See the PF showcase on how to use it, or one of the many duplicate questions in stackoverflow – Kukeltje Sep 04 '15 at 08:24
  • Ok. Would it work if I fill dummy column to achieve that all rows have the same column count? A log warning would be nice in this case. – opfau Sep 04 '15 at 08:34
  • Just read the duplicate, it is all in there... – Kukeltje Sep 04 '15 at 08:36

0 Answers0