I need to draw a tree grid with selecting and scrolling to a specific record initially.开发者_运维百科 I tried the following code. The selection works, but the scrolling doesn't. What is the solution?
treeGrid.addDataArrivedHandler(new DataArrivedHandler() {
public void onDataArrived(DataArrivedEvent event) {
TreeNode node = treeGrid.getData().find("ID", id);
treeGrid.selectRecord(node);
treeGrid.scrollToRow(treeGrid.getRecordIndex(node));
}
}
});
I had the same problem with a ListGrid and solved it by wrapping the scrollToRow command in this:
DeferredCommand.addCommand(new Command() {
public void execute() {
grid.scrollToRow();
}
};
solution found here.
now DeferredCommand is deprecated, so...
Scheduler.get().scheduleDeferred(new Command() {
public void execute() {
grid.scrollToRow();
}
});
will be better.
精彩评论