jsf - How to conditionally render or style a row of primefaces dataTable? -


inside p:datatable, trying render rows need. code:

<h:form id="f">     <p:datatable var="order"         value="#{mbordercontroller.orderslist}">         <f:facet name="header">#{msg.orders}</f:facet>          <p:column sortby="#{order.ordernr}"             headertext="#{msg.order_number}">             <p:outputlabel value="#{order.ordernr}"                 rendered="#{order.type.label == 'shoes'}" />         </p:column>          <p:column sortby="#{order.date}" headertext="#{msg.date}">             <p:outputlabel value="#{order.date}">                 <f:convertdatetime pattern="dd.mm.yy" />             </p:outputlabel>         </p:column>          <p:column sortby="#{order.type.label}" headertext="#{msg.type}">             <p:outputlabel value="#{order.type.label}" />         </p:column>     </p:datatable> </h:form> 

the order type label (third column) enumeration , can "shoes", "shirts" or "pants". want display rows "shoes".

tried add rendered attribute first p:outputlabel hides output label of course. if add rendered attribute each p:outputlabel in table, lowest row in table still visible, although cells empty:

empty row

how can display specific rows using shown rendered attribute? can help?

in attempt, you're indeed conditionally rendering <td> contents, not <tr>. conditionally rendering <tr> of <p:datatable> unfortunately not possible.

you have 2 options:

  1. fix model it's view expects.

    <p:datatable value="#{mbordercontroller.shoesorderslist}" var="shoesorder"> 
  2. use rowstyleclass hide or style specific rows css.

    hiding:

    <p:datatable ... rowstyleclass="#{order.type.label == 'shoes' ? 'ui-helper-hidden' : ''}"> 

    styling:

    <p:datatable ... rowstyleclass="#{order.type.label == 'shoes' ? 'shoestyle' : ''}"> 

    and defining class selector containing 'shoestyle' in css (taking css specificity account)


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -