Data Table Header (Scrolling and Sorting)
Posted: 13 Oct 2010, 16:46
When I create a data table that is scrollable and sortable I am having a problem with the headers. If I sort on one of the columns the column widths change but the headers do not. This makes them no longer line up.
SAMPLE CODE
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.prime.com.tr/ui">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</h:head>
<h:body>
<p:panel >
<h:form id="form1">
<p:dataTable var="prop" value="#{propList.propList}" scrollable="true" height="150">
<p:column sortBy="#{prop.propPropertyId}" >
<f:facet name="header">
<h:outputText value="Property ID" />
</f:facet>
<h:outputText value="#{prop.propPropertyId}" />
</p:column>
<p:column sortBy="#{prop.propName}">
<f:facet name="header">
<h:outputText value="Prop Name" />
</f:facet>
<h:outputText value="#{prop.propName}" />
</p:column>
</p:dataTable>
</h:form>
</p:panel>
</h:body>
</html>
SAMPLE CODE
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.prime.com.tr/ui">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</h:head>
<h:body>
<p:panel >
<h:form id="form1">
<p:dataTable var="prop" value="#{propList.propList}" scrollable="true" height="150">
<p:column sortBy="#{prop.propPropertyId}" >
<f:facet name="header">
<h:outputText value="Property ID" />
</f:facet>
<h:outputText value="#{prop.propPropertyId}" />
</p:column>
<p:column sortBy="#{prop.propName}">
<f:facet name="header">
<h:outputText value="Prop Name" />
</f:facet>
<h:outputText value="#{prop.propName}" />
</p:column>
</p:dataTable>
</h:form>
</p:panel>
</h:body>
</html>