I have issue with RichFaces extended dataTable
If the columns are more say 20, instead of giving a horizontal scroll bar, the columns are getting compressed.
I tried giving column width in %, px .But no use.
Anyone familiar with this?
<rich:column label="Select" sortable="false" width="10%">
<f:facet name="header">
<h:selectBooleanCheckbox id="chk" align="center"
value="#{bean.selectAll}" onclick="selectAll();"/>
</f:facet>
<input id="part_#{rowKey}" type="checkbox"
name="selectedParts" value="#{listVar.id}" />
</rich:column>
<rich:extendedDataTable>really doesn’t handle horizontal scrolling very well. In fact, it seems like the developers set out to make horizontal scrolling next to impossible.You can put
<rich:extendedDataTable>in a<div>with horizontal scrolling enabled, but it’s not going to work if you leave it at that. One of the nested<div>s in<rich:extendedDataTable>(div.extdt-innerdiv) is absolutely positioned, removing it from the flow of the document.For reference, this is the basic output structure of
<rich:extendedDataTable>, assuming three<rich:column>elements with a width of 100px and two records:You could add horizontal scrolling to
div.extdt-innerdiv, but<rich:extendedDataTable>‘s column auto-resizing functionality (ExtendedDataTable.DataTable_formId_edtId.calculateWidthsFromRatios()) essentially gets confused by this, resizing all columns that begin past the component’smaxWidth(derived from the initial width ofdiv.extdt-maindiv) to 20px wide.I’ve tried…
<rich:extendedDataTable>with a<div>element and setting the following:position: relative;width: 100%;overflow-x: auto;div.extdt-maindivabsolutely-positioneddiv.extdt-outerdivanddiv.extdt-innerdivstatic positioning and auto widths…but that doesn’t seem to have any effect.
I’m thinking it may be due to the fact that I’m making most of these changes in Firebug, and
mainDiv.getWidth()(fromcalculateWidthsFromRatios()) is retrieving a cached value,mainDiv.element.boxWidth. This value is being set inClientUI.common.box.Box.setWidth()(common-scrollable-data-table.js), and it’s only called once; it does not get called again if I resize the browser window (the<rich:extendedDataTable>in my case has 100% width).I will try making these changes in my CSS file to see if everything just magically works. The JavaScript for
<rich:extendedDataTable>is pretty complex, though, and it’s not documented, so I could be missing something somewhere. I’ll follow up with my results.EDIT: After making the changes in my CSS, I still experienced the column-shortening problem.
So, to avoid having to create a wrapper div, I added horizontal scrolling to
div.extdt-innerdiv:Then, in the footer of the
<rich:extendedDataTable>, I disabled thecalculateWidthsFromRatios()function:I used the footer of the table in order to force this JavaScript to execute every time the component reRendered.
Even with this solution, the user won’t be able to manually expand the widths of the columns, because the JavaScript in extended-data-table.js prevents columns from being resized wider than
mainDiv.element.boxWidth. In order to enable resizing like this, one might as well just submit a patch to JBoss to fix<rich:extendedDataTable>, as there are currently no plans to modify its behavior in RichFaces 3.X (according to #RF-4871 in the JBoss Community JIRA).Good luck.