<rich:extendedDataTable>
本当に水平スクロールをうまく処理しません。実際、開発者は水平スクロールをほぼ不可能にしようと試みたようです。
<rich:extendedDataTable>
水平スクロールを有効にして入れることはできますが<div>
、そのままにしておくと機能しません。( )内のネストされた<div>
sの1つは絶対に配置され、ドキュメントのフローから削除されます。<rich:extendedDataTable>
div.extdt-innerdiv
参考までに、これはの基本的な出力構造であり、幅が100pxの3つの要素と2つのレコードを<rich:extendedDataTable>
想定しています。<rich:column>
<div id="form_id:edt_id" class="extdt-maindiv rich-extdt-maindiv">
<div id="form_id:edt_id:od" class="extdt-outerdiv">
<div id="form_id:edt_id:innerd" class="extdt-innerdiv">
<table id="form_id:edt_id:tu" class="extdt-table-layout">
<colgroup id="form_id:edt_id:colgroup:header">
<col width="100" />
<col width="100" />
<col width="100" />
</colgroup>
<thead id="form_id:edt_id:header" class="extdt-thead">
<tr class="extdt-subheader rich-extdt-subheader">
<th id="form_id:edt_id:column_1_id" class="extdt-menucell extdt-subheadercell rich-extdt-subheadercell">Column Header 1</th>
<th id="form_id:edt_id:column_2_id" class="extdt-menucell extdt-subheadercell rich-extdt-subheadercell">Column Header 2</th>
<th id="form_id:edt_id:column_3_id" class="extdt-menucell extdt-subheadercell rich-extdt-subheadercell">Column Header 3</th>
</tr>
<tr class="extdt-table-filterrow rich-extdt-subheader"> <!-- only if filtering is enabled -->
<th class="extdt-subheadercell rich-extdt-subheadercell"><!-- omitted for example purposes --></th>
<th class="extdt-subheadercell rich-extdt-subheadercell"><!-- omitted for example purposes --></th>
<th class="extdt-subheadercell rich-extdt-subheadercell"><!-- omitted for example purposes --></th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="3">
<div id="form_id:edt_id:sd" class="extdt-content">
<table id="form_id:edt_id:n" class="extdt-table-layout">
<colgroup id="form_id:edt_id:colgroup:body">
<col width="100" />
<col width="100" />
<col width="100" />
</colgroup>
<tbody id="form_id:edt_id:tb">
<tr id="form_id:edt_id:n:0" class="extdt-firstrow rich-extdt-firstrow">
<td id="form_id:edt_id:0:column_1_id" class="extdt-cell rich-extdt-cell">
<div class="extdt-cell-div">Column 1, Row 1</div>
</td>
<td id="form_id:edt_id:0:column_2_id" class="extdt-cell rich-extdt-cell">
<div class="extdt-cell-div">Column 2, Row 1</div>
</td>
<td id="form_id:edt_id:0:column_3_id" class="extdt-cell rich-extdt-cell">
<div class="extdt-cell-div">Column 3, Row 1</div>
</td>
</tr>
<tr id="form_id:edt_id:n:1" class="extdt-firstrow rich-extdt-firstrow">
<td id="form_id:edt_id:1:column_1_id" class="extdt-cell rich-extdt-cell">
<div class="extdt-cell-div">Column 1, Row 2</div>
</td>
<td id="form_id:edt_id:1:column_2_id" class="extdt-cell rich-extdt-cell">
<div class="extdt-cell-div">Column 2, Row 2</div>
</td>
<td id="form_id:edt_id:1:column_3_id" class="extdt-cell rich-extdt-cell">
<div class="extdt-cell-div">Column 3, Row 2</div>
</td>
</tr>
</tbody>
</table>
</div>
</td>
</tr>
</tbody>
<tfoot id="form_id:edt_id:footer">
<tr class="extdt-footer rich-extdt-footer">
<td class="extdt-footercell rich-extdt-footercell" scope="colgroup" colspan="3">
<!-- table footer goes here if defined -->
</td>
</tr>
</tfoot>
</table>
</div>
</div>
<div id="form_id:edt_id:column_1_idmenu">
<script type="text/javascript">
// context menu script snipped for example purposes
</script>
</div>
<div id="form_id:edt_id:column_2_idmenu">
<script type="text/javascript">
// context menu script snipped for example purposes
</script>
</div>
<div id="form_id:edt_id:column_3_idmenu">
<script type="text/javascript">
// context menu script snipped for example purposes
</script>
</div>
</div>
に水平スクロールを追加することもできますがdiv.extdt-innerdiv
、<rich:extendedDataTable>
の列の自動サイズ変更機能( )は基本的にこれによって混乱し、コンポーネント(の初期幅から派生)をExtendedDataTable.DataTable_formId_edtId.calculateWidthsFromRatios()
超えて始まるすべての列のサイズを20px幅に変更します。maxWidth
div.extdt-maindiv
私はもう試した...
- 要素でラップ
<rich:extendedDataTable>
し<div>
、以下を設定します。
position: relative;
width: 100%;
overflow-x: auto;
- 希望の高さ。それ以外の場合は、次の箇条書きのためにスクロールバーが表示されます。
div.extdt-maindiv
絶対的な位置を作る
- 静的ポジショニングと自動幅の両方
div.extdt-outerdiv
を与えるdiv.extdt-innerdiv
...しかし、それは何の効果もないようです。
mainDiv.getWidth()
これは、Firebugでこれらの変更のほとんどを行っており、 (からcalculateWidthsFromRatios()
)キャッシュされた値を取得していることが原因である可能性があると考えていますmainDiv.element.boxWidth
。この値はClientUI.common.box.Box.setWidth()
(common-scrollable-data-table.js)で設定されており、一度だけ呼び出されます。ブラウザウィンドウのサイズを変更しても、再度呼び出されることはありません(<rich:extendedDataTable>
私の場合は幅が100%です)。
CSSファイルにこれらの変更を加えて、すべてが魔法のように機能するかどうかを確認します。ただし、のJavaScript<rich:extendedDataTable>
はかなり複雑で、文書化されていないため、どこかで何かが欠落している可能性があります。結果をフォローアップします。
編集:CSSに変更を加えた後も、列が短くなる問題が発生しました。
したがって、ラッパーdivを作成する必要がないように、水平スクロールをdiv.extdt-innerdiv
次のように追加しました。
.extdt-innerdiv { overflow-y: hidden; overflow-x: auto !important; }
次に、のフッターで、関数<rich:extendedDataTable>
を無効にしました。calculateWidthsFromRatios()
<rich:extendedDataTable id="edtId">
<!-- rest of extended data table -->
<f:facet name="footer">
<script type="text/javascript">
jQuery(function() {
// Disable ratio-based column resizing.
ExtendedDataTable.DataTable_formId_edtId.calculateWidthsFromRatios = function() {};
});
</script>
</f:facet>
</rich:extendedDataTable>
コンポーネントが再レンダリングされるたびにこのJavaScriptを強制的に実行するために、テーブルのフッターを使用しました。
このソリューションを使用しても、extended-data-table.jsのJavaScriptにより列のサイズが。より広くなることが防止されるため、ユーザーは列の幅を手動で拡張できませんmainDiv.element.boxWidth
。このようなサイズ変更を有効にするには、JBossにパッチを送信して修正する<rich:extendedDataTable>
こともできます。現在、RichFaces 3.Xでの動作を変更する予定はありません(JBoss Community JIRAの#RF-4871による)。
幸運を。