How to add Widget as a Cell in Cell Table GWT

不问归期 提交于 2019-12-10 11:02:43

问题


Now I'm stuck in issue of pagination the widgets in GWT.

I'm using Cell table to display a list of instances of an UI Binder class of mine (Ex: LocationView). http://gwt.google.com/samples/Showcase/Showcase.html#!CwCellTable This is the showcase of the CellTable.

Now I want to add my widget (UI Binder class) to each cell of the table . It will look somehow like this

In this Cell Table, each cell is this widget (LocationView - an UI Binder Class):

So How can I create this table using cell table (I do not use grid view because it's not supported pagination)

or If I can not use Cell table to create this table, what I can use to it that supports pagnigation (if the number of LocationView (The icon you see) is over 6, it will jump to page 2).

Thank you for your help!.


回答1:


Creating custom cells tutorial explains how to do that.




回答2:


To add a widget to a cell I use custom CellTableBuilder and I set unique id for the cell that should contain a widget. Then I attach the widget to DOM and move it to the cell.

void addWidgetToCell(final String cellId, final Widget widget) {
    Scheduler.get().scheduleDeferred(new ScheduledCommand() {
        @Override
        public void execute() {
            Element cellElem = DOM.getElementById(cellId);

            if (!widget.isAttached()) {
                // attach the detail to DOM (cannot attach it directly to the cell, because it has existing parent widget)
                RootPanel.get().add(widget);
            }
            // move detail element under the cell element
            cellElem.appendChild(widget.getElement());
        }
    });
}


来源:https://stackoverflow.com/questions/8642622/how-to-add-widget-as-a-cell-in-cell-table-gwt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!