如何在不滚动DataGrid组件的情况下进行数据绑定? [英] How to data bind DataGrid component without scrolling up?

查看:154
本文介绍了如何在不滚动DataGrid组件的情况下进行数据绑定?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个DataGrid组件,我想每5秒更新一次。由于行被添加到此DataGrid中,我注意到每次更新导致它将滚动条位置重置到顶部。我如何设法将滚动条保持在以前的位置?

I have a DataGrid component that I would like to update every 5 seconds. As rows are being added to this DataGrid I noticed that every update causes it to reset the scroll bar position to the top. How can I manage to keep the scroll bar at its previous position?

推荐答案

我写了一个扩展类到$ c> DataGrid 基于这篇文章。它似乎工作得很好。

I wrote a little extension class to DataGrid based on this article. It seems to work great.

public final class DataGridEx extends DataGrid
{
    public var maintainScrollAfterDataBind:Boolean = true;

    public function DataGridEx()
    {
        super();
    }       

    override public function set dataProvider(value:Object):void {
        var lastVerticalScrollPosition:int = this.verticalScrollPosition;
        var lastHorizontalScrollPosition:int = this.horizontalScrollPosition;

        super.dataProvider = value;

        if(maintainScrollAfterDataBind) {
            this.verticalScrollPosition = lastVerticalScrollPosition;
            this.horizontalScrollPosition = lastHorizontalScrollPosition;
        }
}   

这篇关于如何在不滚动DataGrid组件的情况下进行数据绑定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆