我有一个树控件,在我将一个项目放入其中(更新数据提供程序)后,我希望它保持打开状态。我尝试了很多东西,包括 this question 中的示例我无法上类,所以我正在做一些我认为更基本的事情。像这样:
[Bindable]
public var open:Object = new Object();
private function dropItemInTree():void{
open = myTree.openItems;
//A bunch of code that updates the DP
reopenTree();
}
public function reopenTree():void{
for each(var item:XML in open){
expandParents(item[0]);
}
}
private function expandParents(node:XML):void {
myTree.expandItem(node,true,false);
}
但即便如此,我的树也被最小化了。出了什么问题?
最佳答案
所以我终于弄清楚发生了什么。在我的 drop 函数中,我基本上重建了整个 DP。虽然几乎相同,但在 Flash 播放器内会有不同的 UID,因此 open var 中的对象不再引用 DP 中的对象。幸运的是,我的 XML 数据提供程序中有一个 ID 字段,因此我可以使用该字段在重建的 DP 中查找该对象,并最终让 ExpandItem 方法在那里工作。
所以我的重新打开函数现在看起来像这样:
public function renderTree():void
for each(var item:XML in open){
myTree.expandItem(XML(MyDP..node.(@attr == item.@attr)),true);
//forcing the type to be XML is VITAL
}
}
关于apache-flex - Flex 树不重新扩展,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2230748/