开发者

How do I set first column width on GWT CellBrowser

There is a bug preventing the setting of the first column width of the CellBrowser widget. There is also a workaround, explained here

http://groups.google.com/group/google-web-toolkit/browse_thread/thread开发者_开发问答/4fc39b5805833ea2

Apparently it works, but can anybody explain how to subclass the CellBrowser to make it work? Please show me some code.


    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);   
  • from the thread linked to in the question: http://groups.google.com/group/google-web-toolkit/browse_thread/thread/4fc39b5805833ea2

If you wanted a re-usable class with this fix in (which would probably be a good idea), it's simple enough to convert this anonymous subclass into a regular subclass:

    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);
        }
    }

(Note: I have not tried compiling this code.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜