javajsfjsf-2conditional-statementstomahawk

JSF tomahawk t:columns conditional rendering


So, umm, I've got JSF tomahawk table

<t:dataTable ... >
    <t:columns ...>
          ... content to render ...
    </t:columns>
</t:dataTable>

and I want to omit some columns. I can't change data model. Columns total count varies from time to time.

Tried

<t:dataTable ... >
    <t:columns ...>
         <c:if  test="#{condition}">
                ... content to render ...
         </c:if>
    </t:columns>
</t:dataTable>

but it still outputs empty columns.

This answer is not an option: Conditional column rendering

because I use t:columns and not t:column.

How can I omit certain columns when I'm using t:columns?


Solution

  • I add display:none; to the header and row styles if the condition is met (omitting by the header name in this case). The selected column disappears.

    <t:dataTable ... >
        <t:columns var="colH" value="#{dataModel.colHeaders}"  headerstyle="#{colH eq 'frodo'? 'display:none;' : ''}" style="#{colH eq 'frodo'? 'display:none;' : ''}">
              ... content to render ...
        </t:columns>
    </t:dataTable>