开发者

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

开发者 https://www.devze.com 2023-03-13 11:13 出处:网络
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

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

精彩评论

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