0

CellBrowser ウィジェットの最初の列幅の設定を妨げるバグがあります。ここで説明されている回避策もあります

http://groups.google.com/group/google-web-toolkit/browse_thread/thread/4fc39b5805833ea2

どうやらそれは動作しますが、CellBrowser をサブクラス化して動作させる方法を説明できる人はいますか? いくつかのコードを見せてください。

4

1 に答える 1

0
    CellBrowser cellBrowser = new CellBrowser(model, null) {

        // HACK: workaround for setDefaultColumnWidth not setting the width of the first column!
        // SEE: https://groups.google.com/forum/?pli=1#!topic/google-web-toolkit/T8Ob...

        public void setDefaultColumnWidth(int width) {
            super.setDefaultColumnWidth(width);
             SplitLayoutPanel splitPanel =  (SplitLayoutPanel) getWidget();
             splitPanel.setWidgetSize(splitPanel.getWidget(0), width);
        }
    };

    cellBrowser.setDefaultColumnWidth(300);   

この修正を加えた再利用可能なクラスが必要な場合(これはおそらく良い考えです)、この匿名サブクラスを通常のサブクラスに変換するのは簡単です。

    public class FixedCellBrowser<T> extends CellBrowser<T> {

        public FixedCellBrowser(TreeViewModel model, T root) {
            super(model, root);
        }

        public void setDefaultColumnWidth(int width) {
            super.setDefaultColumnWidth(width);
             SplitLayoutPanel splitPanel =  (SplitLayoutPanel) getWidget();
             splitPanel.setWidgetSize(splitPanel.getWidget(0), width);
        }
    }

(注:このコードのコンパイルは試していません。)

于 2011-11-11T16:34:57.820 に答える