Reputation: 97
How to show tooltip for the header of dynamic Table p:dataTable when the mouse over the header to display the entire title of header column.
<p:dataTable id="detailDataTable" widgetVar="detailWidgetVar"
value="#{model.elements}" var="element"
paginator="false" resizableColumns="false" scrollWidth="100%"
scrollable= "true" emptyMessage="Aucun résultat"
styleClass="tableResultat" rowStyleClass="">
<p:columns value="#{model.columns}" var="column" columnIndexVar="colIndex"
headerText="#{column.header}"
styleClass="#{column.styleClass}" width="#{column.width}"
sortBy="#{(element[column.productId])[column.property]}">
<h:outputText value="#{(element[column.productId])[column.property]}"
title="#{(element[column.productId])[column.property]}"/>
</p:columns>
</p:dataTable>
Upvotes: 6
Views: 12761
Reputation: 20691
You could use the Global Primefaces Tooltip; You just need to change your approach to setting the header text, using the <f:facet/>
rather than the headerText
attribute. Using your code sample
<p:tooltip/>
<p:columns value="#{model.columns}" var="column" columnIndexVar="colIndex"
headerText= styleClass="#{column.styleClass}" width="#column.width}" sortBy="#{(element[column.productId])[column.property]}">
<f:facet name="header">
<h:outputText value="#{column.header}" title="#{column.header}"/>
</f:facet>
<h:outputText value="#{(element[column.productId])[column.property]}" title="#{(element[column.productId])[column.property]}"/>
</p:columns>
Two things have happened
<p:tooltip/>
title
attribute on the header facet text. This is what hooks into the global tooltip, to display tooltip text per columnUpvotes: 13