问题
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