【发布时间】:2009-02-26 20:05:50
【问题描述】:
我有一个带有 HierarchicalData 数据提供者的 AdvancedDataGrid (ADG):
<mx:AdvancedDataGrid xmlns:mx="http://www.adobe.com/2006/mxml"
dataProvider="{__model.myHierarchicalData}"
displayItemsExpanded="true" sortExpertMode="true" dropEnabled="true"
sortableColumns="false" draggableColumns="false"
resizableColumns="true" textAlign="left" defaultLeafIcon="{null}"
folderOpenIcon="{null}" folderClosedIcon="{null}"/>
当我最初在 Model 中设置 HierarchicalData 实例时,它按预期显示:
function buildHierarchicalData(parentItems:ArrayCollection):void
{
__model.myHierarchicalData = new HierarchicalData();
__model.myHierarchicalData.source = parentItems;
}
parentItems 是 ParentItem valueObjects 的集合:
package
{
[Bindable]
public class ParentItem
{
public var children:ArrayCollection;
public var label:String;
}
}
但是,当我将子项从一个父项移动到另一个父项(通过拖放)时,更新不可见,使用以下代码:
function moveChildren(movedChildren:Array /* of ParentItem */):void
{
parentItem.children = new ArrayCollection(movedChildren);
}
但是,由于某种原因,这确实有效:
function moveChildren(movedChildren:Array /* of ParentItem */):void
{
parentItem.children.source = movedChildren;
}
为什么一定要更新ArrayCollection的来源???
【问题讨论】:
-
尝试让孩子可以绑定。
-
对不起,它可以在我的代码中绑定(参见上面的固定帖子)。
标签: apache-flex actionscript-3 hierarchical-data advanceddatagrid