开发者

How to scroll to a specific record in a treegrid with smartgwt when it's initially drawed?

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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜