12

RichFaces 拡張 dataTable に問題があります

列が 20 を超える場合、水平スクロール バーが表示されるのではなく、列が圧縮されています。

列幅を %, px で指定しようとしましたが、使い物になりません。

これに詳しい人はいますか?

<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>
4

5 に答える 5

12

<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幅に変更します。maxWidthdiv.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による)。

幸運を。

于 2010-02-02T18:54:02.460 に答える
5

「px」または「%」なしで幅を指定する必要があります。

<rich:column label="Select" sortable="false" width="100">

Extended Datatable には水平スクロールの問題がありますが、固定のテーブル幅をピクセル単位で指定し、overflow-x をスクロールに設定してテーブルを div に配置できます。

于 2009-11-09T10:47:11.037 に答える
3

私はあらゆる種類のアイデアを組み合わせて、次のことを思いつきました。

前述のとおり、修正すべき点があります。1 つはテーブル幅の 100% を超えるスクロール可能性で、もう 1 つはスクロールバー自体です。したがって、サイズ変更の問題を修正するためのjsファイルと、スクロールバーを追加するためのcssがあります...

page.xhtml - 内部に拡張 dt を含むページ。

<head>
    <a4j:loadStyle
        src="resource:///org/company/project/css/ExtendedDatatableFix.css"
        media="screen" />
    <a4j:loadScript
        src="resource:///org/company/project/js/ExtendedDataTableHeaderFixScrollable.js" />
</head>
<body>
    <!-- prevent IE to come up with ExtendedDataTable-bla not defined-js-error -->
    <rich:extendedDataTable id="dummy_table_for_extended_datatable_fix" rendered="false">
    </rich:extendedDataTable>


    <rich:extendedDataTable id="here_goes_your_datatable">
        <!-- your ext-dt -->
    </rich:extendedDataTable>
</body>

ExtendedDatatableFix.css - それほど正確ではありませんが、改善の余地があります

.extdt-maindiv {
    margin-bottom: 17px;
}
.extdt-outerdiv {
    overflow-x:auto !important;
    overflow-y:hidden;
    height: 108% !important;
}
.extdt-innerdiv {
    height: 100% !important;
}
.extdt-content{
    overflow-x:hidden;
    overflow-y:scroll;
}

ExtendedDataTableHeaderFixScrollable.js - ここからコピー: http://community.jboss.org/thread/146108

 ExtendedDataTable.DataTable.header.prototype.OnSepMouseMove = function(event) {
      if(this.dragColumnInfo && this.dragColumnInfo.mouseDown) {
           if(!this.dragColumnInfo.dragStarted) {
                this.dragColumnInfo.dragStarted = true;
                this._showSplitter(this.dragColumnInfo.srcElement.columnIndex);
           }
           var delta = Event.pointerX(event) - 
                this.dragColumnInfo.startX
           if (delta < this.minDelta) {
                delta = this.minDelta;
           }
           /*if (delta > this.maxDelta) {
                delta = this.maxDelta;
           }*/
           var x = this.dragColumnInfo.originalX + delta;
           var finalX = x - this.minColumnWidth - 6 //6 stands for sep span width;
           this.columnSplitter.moveToX(finalX);                     
           Event.stop(event);
      }
 }

 ExtendedDataTable.DataTable.header.prototype.OnSepMouseUp = function(event) {
      Event.stop(event);
      Event.stopObserving(document, 'mousemove', this.eventSepMouseMove);
      Event.stopObserving(document, 'mouseup', this.eventSepMouseUp);
      if(this.dragColumnInfo && this.dragColumnInfo.dragStarted) {
           this.dragColumnInfo.dragStarted = false;
           this.dragColumnInfo.mouseDown = false;

           var delta = Event.pointerX(event) - 
                this.dragColumnInfo.startX;
           if (delta < this.minDelta) {
                delta = this.minDelta;
           }
           /*if (delta > this.maxDelta) {
                delta = this.maxDelta;
           }*/
           var columnIndex = this.dragColumnInfo.srcElement.columnIndex;
           var newWidth = this.getColumnWidth(columnIndex) + delta;

           this.extDt.setColumnWidth(columnIndex, newWidth);
           this.setColumnWidth(columnIndex,newWidth);
           this.extDt.updateLayout();
           if (this.extDt.onColumnResize){
                //set properly value to this.columnWidths
                this.extDt.columnWidths = "";
                for (i=0; i<this.columnsNumber; i++){
                     this.extDt.columnWidths += "" + this.getColumnWidth(i) + ";";
                }//for
                this.extDt.onColumnResize(event, this.extDt.columnWidths);
           }
      }
      this._hideSplitter();
 }

ExtendedDataTable.DataTable.prototype.calculateWidthsFromRatios = function() {
    LOG.debug('firing calculateWidthsFromRatios');
    var c = this.getColumns();
    var scrollbarWidth = this.getScrollbarWidth();
    this._scrollbarWidth = scrollbarWidth;
    LOG.debug('Scrollbar: ' + scrollbarWidth);
    var mainDivWidth = this.mainDiv.getWidth();
    LOG.debug('Main DIV: ' + mainDivWidth);
    var maxWidth = mainDivWidth - scrollbarWidth;
    LOG.debug('Width to spread: ' + maxWidth);
    var totalWidth = 0;
    for (i = 0; i < c.length - 1; i++) {
        LOG.debug('Column[' + i + '] ratio: ' + this.ratios[i]);
        var w = Math.round(this.ratios[i] * maxWidth);
        if (w < parseInt(this.minColumnWidth)) {
            w = parseInt(this.minColumnWidth);
        }
        LOG.debug('setting column ' + i + ' to width: ' + w);
        this.setColumnWidth(i, w);
        this.header.setColumnWidth(i, w);
        totalWidth += w;
    }
    /*
     * if (totalWidth > maxWidth) {
     * c[c.length - 2].width -= (totalWidth - maxWidth);
     * }
     */
};
于 2010-11-17T10:48:44.683 に答える
0

この例によると、次のとおりです。

RichFaces ショーケース

幅は次のように使用されます (xhtml のソースを確認してください)。

<rich:column filter="#{carsFilteringBean.mileageFilterImpl}" width="150px"

私にとっては問題なく動作しました。

ご挨拶。

于 2013-06-26T17:45:16.713 に答える
0

水平スクロールバーを有効にするには、https://jira.jboss.org/jira/browse/RF-4871の回避策を参照してください。

水平スクロールバーが表示されているときに列のサイズを変更できるようにするには、このhttp://community.jboss.org/message/518878#518878を参照してください。

于 2010-11-08T08:18:47.533 に答える