flex tree 获得选中当前节点的所有父节点
flextree获得选中当前节点的所有父节点,我的数据源是ArrayConnction,求点代码参考!能给我你怎么实现的代码吗,非常感谢...
flex tree 获得选中当前节点的所有父节点,我的数据源是ArrayConnction,求点代码参考!能给我你怎么实现的代码吗,非常感谢
展开
展开全部
第一,你在制作数据源的时候,需要为子节点的数据源指定一个属性parent
private function packQuanXianTreeData(quanXianTreeDataTemp:ArrayCollection):void
{
var quanXianTreeData_:ArrayCollection = new ArrayCollection();
if(quanXianTreeDataTemp.length>0)
{
for each(var obj1:Object in quanXianTreeDataTemp)
{
if(obj1.hasOwnProperty('levels')&&obj1['levels'] == 1)
{
quanXianTreeData_.addItem(obj1);
}
}
var sort:Sort = new Sort();
sort.fields = [new SortField("sort")];
quanXianTreeData_.sort = sort;
quanXianTreeData_.refresh();
for each(var obj2:Object in quanXianTreeDataTemp)
{
var children:ArrayCollection = new ArrayCollection();
for each(var obj3:Object in quanXianTreeDataTemp)
{
if(obj3.hasOwnProperty('pid')&&obj3['pid']==obj2['id'])
{
obj3.parent = obj2;
children.addItem(obj3);
}
}
if(children.length>0)
{
children.sort = sort;
children.refresh();
obj2.children = children;
}
}
}
this.quanXianTreeData = quanXianTreeData_;
}
第二,获得父节点的方法。参数obj:Object为选中的节点,参数ac:ArrayCollection为装父节点的集合。
private function getCondition(obj:Object,ac:ArrayCollection):void
{
var parent:Object;
if(obj.hasOwnProperty("parent")&&obj['parent']!=null)
{
parent = obj['parent'];
}
ac.addItemAt(obj,0);
if(parent!=null)
{
getCondition(parent,ac);
}
}
2013-08-06
展开全部
var parentData = tree.dataDescriptor.getParent(tree.selectedItem, tree.dataProvider);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询