存储和更新Flex AdvancedDataGrid的分层数据的最有效方法是什么?

时间:2022-09-23 17:48:24

I have a Flex application that has an AdvancedDataGrid that displays hierarchical data in a tree. I'm currently storing this data in XML and it's being updated about every second. This was working well for a while, but the amount of data I have to store and update has increased lately and it's slowing down the application to the point that it's becoming unusable and crashing frequently.

我有一个Flex应用程序,它有一个AdvancedDataGrid,可以在树中显示分层数据。我目前正在以XML格式存储这些数据,并且每秒都在更新。这一段时间运行良好,但是我必须存储和更新的数据量最近有所增加,并且它正在减慢应用程序的速度,使其变得无法使用并经常崩溃。

So I need a more efficient way to store, update, and access this data. The main requirement is that whatever I use to store the data needs to be able to be converted to a HierarchicalData object that I can use as the data provider for my AdvancedDataGrid (to enable the tree display).

所以我需要一种更有效的方式来存储,更新和访问这些数据。主要要求是我用于存储数据的任何东西都需要能够转换为HierarchicalData对象,我可以将其用作AdvancedDataGrid的数据提供者(以启用树形显示)。

I'm thinking about trying an ArrayCollection, since that's the only other type shown in the Adobe provided examples (http://livedocs.adobe.com/flex/3/html/help.html?content=advdatagrid_06.html). Would this be more efficient than using XML? Is there another data type that might be even faster to access than either of these?

我正在考虑尝试一个ArrayCollection,因为这是Adobe提供的示例中显示的唯一其他类型(http://livedocs.adobe.com/flex/3/html/help.html?content=advdatagrid_06.html)。这比使用XML更有效吗?还有其他数据类型可能比其中任何一种更快访问吗?

1 个解决方案

#1


0  

Whenever I am performing many update or search operations on a data structure, I always convert any serial data (xml, json, etc.) to strongly typed model classes. This will allow data operations to execute as quickly as possible. The AdvancedDataGrid uses the HierarchicalData class to describe the structure, so you just need to make sure your model conforms to that structure (or create a custom descriptor).

每当我在数据结构上执行许多更新或搜索操作时,我总是将任何串行数据(xml,json等)转换为强类型模型类。这将允许数据操作尽快执行。 AdvancedDataGrid使用HierarchicalData类来描述结构,因此您只需确保模型符合该结构(或创建自定义描述符)。

For example:

public class MyBranchNode extends EventDispatcher
{
    public function MyBranchNode(data:XML, target:IEventDispatcher = null)
    {
        super(target);

        setMemento(data);
    }

    public var children:Array;

    private var _label:String;

    [Bindable(event = "labelChange")]
    public function get label():String
    {
        return _label;
    }

    public function set label(value:String):void
    {
        if(_label == value)
            return;

        _label = value;
        this.dispatchEvent(new Event("labelChange"));
    }

    /**
     * Parse your XML into into binary data
     */
    private function setMemento(data:XML):void
    {
        this.label = data.label;

        for each(var child:XML in data.children())
        {
            if(this.children == null)
                this.children = [];

            this.children.push(new MyLeafNode(child));
        }
    }
}



public class MyLeafNode extends EventDispatcher
{
    public function MyLeafNode(data:XML, target:IEventDispatcher = null)
    {
        super(target);

        setMemento(data);
    }

    private var _label:String;

    [Bindable(event = "labelChange")]
    public function get label():String
    {
        return _label;
    }

    public function set label(value:String):void
    {
        if(_label == value)
            return;

        _label = value;
        this.dispatchEvent(new Event("labelChange"));
    }

    /**
     * Parse your XML into into binary data
     */
    private function setMemento(data:XML):void
    {
        this.label = data.label;
    }
}

#1


0  

Whenever I am performing many update or search operations on a data structure, I always convert any serial data (xml, json, etc.) to strongly typed model classes. This will allow data operations to execute as quickly as possible. The AdvancedDataGrid uses the HierarchicalData class to describe the structure, so you just need to make sure your model conforms to that structure (or create a custom descriptor).

每当我在数据结构上执行许多更新或搜索操作时,我总是将任何串行数据(xml,json等)转换为强类型模型类。这将允许数据操作尽快执行。 AdvancedDataGrid使用HierarchicalData类来描述结构,因此您只需确保模型符合该结构(或创建自定义描述符)。

For example:

public class MyBranchNode extends EventDispatcher
{
    public function MyBranchNode(data:XML, target:IEventDispatcher = null)
    {
        super(target);

        setMemento(data);
    }

    public var children:Array;

    private var _label:String;

    [Bindable(event = "labelChange")]
    public function get label():String
    {
        return _label;
    }

    public function set label(value:String):void
    {
        if(_label == value)
            return;

        _label = value;
        this.dispatchEvent(new Event("labelChange"));
    }

    /**
     * Parse your XML into into binary data
     */
    private function setMemento(data:XML):void
    {
        this.label = data.label;

        for each(var child:XML in data.children())
        {
            if(this.children == null)
                this.children = [];

            this.children.push(new MyLeafNode(child));
        }
    }
}



public class MyLeafNode extends EventDispatcher
{
    public function MyLeafNode(data:XML, target:IEventDispatcher = null)
    {
        super(target);

        setMemento(data);
    }

    private var _label:String;

    [Bindable(event = "labelChange")]
    public function get label():String
    {
        return _label;
    }

    public function set label(value:String):void
    {
        if(_label == value)
            return;

        _label = value;
        this.dispatchEvent(new Event("labelChange"));
    }

    /**
     * Parse your XML into into binary data
     */
    private function setMemento(data:XML):void
    {
        this.label = data.label;
    }
}