{"id":1046,"date":"2010-11-08T13:18:30","date_gmt":"2010-11-08T13:18:30","guid":{"rendered":"http:\/\/salientsoft.co.uk\/?p=1046"},"modified":"2010-11-08T13:23:08","modified_gmt":"2010-11-08T13:23:08","slug":"header-width-incorrect-on-primefaces-scrollable-table","status":"publish","type":"post","link":"https:\/\/salientsoft.co.uk\/?p=1046","title":{"rendered":"Header width incorrect on Primefaces scrollable table"},"content":{"rendered":"<p>If a header facet is used on a Primefaces table, the header does not allow for the scrollbars if present. the column headers do adjust for the scrollbars (although there are issues with column alignment between the headers and the data \u2013 a number of such errors have been posted to the Primefaces forum).<\/p>\n<p>One workaround for this is to selectively include a CSS selector to adjust the header &lt;div&gt; width when the scrollbars are present.<br \/>\nThe following selector achieves this:-<\/p>\n<p style=\"padding-left: 30px;\">&lt;style type=&#8221;text\/css&#8221;&gt;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/p>\n<p style=\"padding-left: 30px;\">\u00a0\u00a0\u00a0 .ss-tableheader-scrolladjust &gt; div.ui-datatable-header {<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 width:495px;<br \/>\n\u00a0\u00a0\u00a0 }<br \/>\n&lt;\/style&gt;<\/p>\n<p>The following table definition selectively includes this when enough rows are present to require scroll bars (this must be derived empirically as it depends on the height of the table, font size used etc. :-<\/p>\n<p style=\"padding-left: 30px;\">\u00a0\u00a0\u00a0\u00a0 &lt;h:panelGroup layout=&#8221;block&#8221; style=&#8221;width:500px;&#8221;&gt;\u00a0\u00a0\u00a0\u00a0<br \/>\n\u00a0\u00a0\u00a0\u00a0 &lt;p:dataTable var=&#8221;car&#8221; value=&#8221;#{tableBean.carsSmall}&#8221; scrollable=&#8221;true&#8221;\u00a0<br \/>\n\u00a0\u00a0\u00a0\u00a0 <strong><em>\u00a0\u00a0\u00a0 styleClass=&#8221;#{fn:length(tableBean.carsSmall) lt 8 ? &#8221; : &#8216;ss-tableheader-scrolladjust&#8217;}&#8221; height=&#8221;200&#8243; &gt;\u00a0<br \/>\n<\/em><\/strong>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;f:facet name=&#8221;header&#8221;&gt;<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ajax Sorting\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;\/f:facet&gt;<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;p:column headerText=&#8221;Model&#8221;\u00a0 sortBy=&#8221;#{car.model}&#8221;&gt;<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;h:outputText value=&#8221;#{car.model}&#8221; \/&gt;<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;\/p:column&gt;<\/p>\n<p style=\"padding-left: 30px;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;p:column headerText=&#8221;Year&#8221;\u00a0 sortBy=&#8221;#{car.year}&#8221;&gt;<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;h:outputText value=&#8221;#{car.year}&#8221; \/&gt;<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;\/p:column&gt;<\/p>\n<p style=\"padding-left: 30px;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;p:column headerText=&#8221;Manufacturer&#8221;\u00a0 sortBy=&#8221;#{car.manufacturer}&#8221;&gt;<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;h:outputText value=&#8221;#{car.manufacturer}&#8221; \/&gt;<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;\/p:column&gt;<\/p>\n<p style=\"padding-left: 30px;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;p:column headerText=&#8221;Color&#8221; sortBy=&#8221;#{car.color}&#8221;&gt;<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;h:outputText value=&#8221;#{car.color}&#8221; \/&gt;<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;\/p:column&gt;<br \/>\n\u00a0\u00a0\u00a0\u00a0 &lt;\/p:dataTable&gt;<br \/>\n\u00a0\u00a0\u00a0 &lt;\/h:panelGroup&gt;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If a header facet is used on a Primefaces table, the header does not allow for the scrollbars if present. the column headers do adjust for the scrollbars (although there are issues with column alignment between the headers and the data \u2013 a number of such errors have been posted to the Primefaces forum). One [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[22],"tags":[13,189,40,184,112,16],"_links":{"self":[{"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/1046"}],"collection":[{"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1046"}],"version-history":[{"count":3,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/1046\/revisions"}],"predecessor-version":[{"id":1049,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/1046\/revisions\/1049"}],"wp:attachment":[{"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1046"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1046"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1046"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}