开发者

A way to keep DataGrid in same scroll position after update?

I have a custom <mx:DataGrid /> that is updated with data from a ColdFusion server every 60 seconds. I've noticed that every time the DataGrid updates and redraws the scroll position is reset to the top.

Is there a way I can preserve the scroll position for 开发者_StackOverflowmy DataGrid?

Thanks in advance.


I'm pretty sure you can use the verticalScrollPosition. Save it before the updated and reset it after the update. Keep in mind that if you're changing the dataProvider, the verticalScrollPosition may not be pointing at the same place in the old and new dataprovider.


Just to provide a bit more detail. The way I did this is create a variable called scrollPos then in

<mx:DataGrid id="someId" I used

scroll="scrollPos=someId.verticalScrollPosition"

Then after the dataProvider is updated I call a function:

private function setScrollPosition() : void {
  someId.verticalScrollPosition = scrollPos;
}

or you can just set the variable instead of calling a function.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜