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:
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:
fix model it's view expects.
<p:datatable value="#{mbordercontroller.shoesorderslist}" var="shoesorder">
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
Post a Comment