Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache flex 如何从AdvancedDataGrid的数据提供程序创建分层游标?_Apache Flex_Actionscript 3_Hierarchical Data_Advanceddatagrid_Cursors - Fatal编程技术网

Apache flex 如何从AdvancedDataGrid的数据提供程序创建分层游标?

Apache flex 如何从AdvancedDataGrid的数据提供程序创建分层游标?,apache-flex,actionscript-3,hierarchical-data,advanceddatagrid,cursors,Apache Flex,Actionscript 3,Hierarchical Data,Advanceddatagrid,Cursors,在我之前编写的一个应用程序中,我有一个扩展了AdvancedDataGrid(ADG)的类。它包含以下代码: package { public class CustomADG extends AdvancedDataGrid { .... // This function serves as the result handler for a webservice call that retrieves XML data. priv

在我之前编写的一个应用程序中,我有一个扩展了AdvancedDataGrid(ADG)的类。它包含以下代码:

package
{
    public class CustomADG extends AdvancedDataGrid
    {
        ....

        // This function serves as the result handler for a webservice call that retrieves XML data.
        private function webServiceResultHandler(event:ResultEvent):void
        {
            var resultXML:XML = new XML(event.result);

            dataProvider = new HierarchicalData(resultXML.children);
        }

        ....

        public function setOpenNodes(maxDepth:int = 0):void
        {
            var dataCursor:IHierarchicalCollectionViewCursor = dataProvider.createCursor();

            while (dataCursor.current != null)
            {
                if (dataCursor.currentDepth < maxDepth)
                    dataProvider.openNode(dataCursor.current);

                dataCursor.moveNext();
            }

            dataProvider.refresh();
        }
    }
}
在父组件中设置数据提供程序:

<view:ReportADG id="reportADG" dataProvider="{reportData}" />
但是,我遇到运行时错误:

TypeError: Error #1034: Type Coercion failed: cannot convert ListCollectionViewCursor@6f14031 to mx.collections.IHierarchicalCollectionViewCursor.
我尝试将数据提供者转换为ICollectionView。然后我尝试将
ICollectionView
转换为
IHierarchicalCollectionView
。我试过各种各样的演员,但似乎都不管用。为什么在这个新的实现中不能像在过去的实现中那样工作?我需要做什么

***更新:

我开始调试这个。我在ADG类中添加了一个覆盖设置器,以查看何时设置数据提供程序:

override public function set dataProvider(value:Object):void
{
    super.dataProvider = value;
}

我向这个setter和setOpenNodes()函数添加了一个断点。果然,dataProvider是在调用setOpenNodes()之前设置的,它是HierarchycalData。但是,当setOpenNodes()调用时,调试器会说dataProvider是null ArrayCollection。这似乎是根本问题。

在尝试访问dataProvider属性之前,我需要调用commitProperties

public function setOpenNodes(maxDepth:int = 0):void
{
    super.commitProperties();

    var dataCursor:IHierarchicalCollectionViewCursor = 
        dataProvider.createCursor();

    while (dataCursor.current != null)
    {
        if (dataCursor.currentDepth < maxDepth)
            dataProvider.openNode(dataCursor.current);

        dataCursor.moveNext();
    }

    dataProvider.refresh();
}
公共函数setOpenNodes(maxDepth:int=0):无效
{
super.commitProperties();
var dataCursor:IHierarchicalCollectionViewCursor=
dataProvider.createCursor();
while(dataCursor.current!=null)
{
如果(dataCursor.currentDepth
在尝试访问dataProvider属性之前,我需要调用commitProperties

public function setOpenNodes(maxDepth:int = 0):void
{
    super.commitProperties();

    var dataCursor:IHierarchicalCollectionViewCursor = 
        dataProvider.createCursor();

    while (dataCursor.current != null)
    {
        if (dataCursor.currentDepth < maxDepth)
            dataProvider.openNode(dataCursor.current);

        dataCursor.moveNext();
    }

    dataProvider.refresh();
}
公共函数setOpenNodes(maxDepth:int=0):无效
{
super.commitProperties();
var dataCursor:IHierarchicalCollectionViewCursor=
dataProvider.createCursor();
while(dataCursor.current!=null)
{
如果(dataCursor.currentDepth
public function setOpenNodes(maxDepth:int = 0):void
{
    super.commitProperties();

    var dataCursor:IHierarchicalCollectionViewCursor = 
        dataProvider.createCursor();

    while (dataCursor.current != null)
    {
        if (dataCursor.currentDepth < maxDepth)
            dataProvider.openNode(dataCursor.current);

        dataCursor.moveNext();
    }

    dataProvider.refresh();
}