JSF h:dataTable creates single empty cell when no records

后端 未结 3 1016
无人及你
无人及你 2020-12-20 16:19

Is there any way to prevent an h:datatable from creating an empty row when the backing value is empty? More specifically: I have a collection of data to be displayed in 3 co

相关标签:
3条回答
  • 2020-12-20 16:33

    Thanks for BalusC's suggestion, but I tried it, it did not work. It may be other reasons result in. I fixed BalusC's code a little, it works now:

    table.locations.empty tbody td {
        border-color: rgba(0, 0, 0, 0);
    }
    
    0 讨论(0)
  • 2020-12-20 16:40

    Specify a separate style for an empty table. E.g.

    table.empty tbody td {
        border: 0;
    }
    

    And add it conditionally.

    <h:dataTable ... styleClass="locations #{empty component.value ? 'empty' : ''}">
    
    0 讨论(0)
  • 2020-12-20 16:52

    You might be able to avoid the column header disapearing if you instead wrap your method in an outputText tag

    Example:

      <h:column>
        <!-- column header -->
        <f:facet name="header">Address</f:facet>
        <!-- row record -->
           <h:outputText value="#{nearestLoc.affffdress}" />
        </h:column>
    

    This way the column itself does not depend on the values

    0 讨论(0)
提交回复
热议问题