Flex Tree 不选择(“突出显示”)selectedIndices
我有一系列应在树控件中选择的项目。正如您从下面的代码中看到的,我将此数组绑定到树的 selectedIndices 属性。 selectedItems 没有在树中正确选择(选择一些其他项目并且始终选择根)。Flex 似乎“忽略”我的项目(选择一些其他索引)。我错过了什么吗?
也许我以错误的方式处理这个问题?
感谢您的帮助!
我的 XMLList:-
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
<fx:XMLList id="XMLList">
<node>
<node name="max">
<node name="Emanuele"
surname="Tatti" age="23" wage="1200"/>
<node name="Francesco"
surname="Rapana " age="22" wage="1000"/>
<node name="Constantin"
surname="Moldovanu" age="23" wage="1200"/>
<node name="Marco"
surname="Casario" age="29" wage="1500">
<node name="Marco"
surname="Casario" age="29" wage="1500">
<node name="Marco"
surname="Casario" age="29" wage="1500">
<node name="Marco"
surname="Casario" age="29" wage="1500">
</node>
</node>
</node>
</node>
</node>
</node>
</fx:XMLList>
</fx:Declarations>
我的动作脚本功能:-
public function select_tree():Void
{
tree.validateNow();
var allItems:Array = new Array();
for(var n:Int =2;n<7;n+2)
{
allItems[n]=n; // o/p- 2,4,6
}
tree.selectedIndices = allItems1; //2,4,6 items should select ,but 0,2,4,5 are selected why?
}
*****My MXML:-*****
<mx:Button id="btn" label="Find Unmatch Nodes" width="221" height="30" click="select_tree()"/>
<mx:Tree id="tree" right="10" top="54" bottom="10" width="49.5%" dataProvider="{XMLList}"
fontFamily="Verdana" fontSize="11" showScrollTips="true"
allowMultipleSelection="true"
alternatingItemColors="[#F5F5F5]"
labelField="@label" selectionColor="#ECF335" showRoot="false"/>
I have an array of items that should be selected in my tree control. As you can see from my code below,I bind this array to the selectedIndices property of the tree.
The selectedItems are not properly selecting in tree(selecting some other items and always root is selected).Flex seems to "ignore" my items (selects some other indices). Am I missing something?
Perhaps I'm going about this in wrong way?
Thanks for your help!
My XMLList:-
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
<fx:XMLList id="XMLList">
<node>
<node name="max">
<node name="Emanuele"
surname="Tatti" age="23" wage="1200"/>
<node name="Francesco"
surname="Rapana " age="22" wage="1000"/>
<node name="Constantin"
surname="Moldovanu" age="23" wage="1200"/>
<node name="Marco"
surname="Casario" age="29" wage="1500">
<node name="Marco"
surname="Casario" age="29" wage="1500">
<node name="Marco"
surname="Casario" age="29" wage="1500">
<node name="Marco"
surname="Casario" age="29" wage="1500">
</node>
</node>
</node>
</node>
</node>
</node>
</fx:XMLList>
</fx:Declarations>
My Action Script Function:-
public function select_tree():Void
{
tree.validateNow();
var allItems:Array = new Array();
for(var n:Int =2;n<7;n+2)
{
allItems[n]=n; // o/p- 2,4,6
}
tree.selectedIndices = allItems1; //2,4,6 items should select ,but 0,2,4,5 are selected why?
}
*****My MXML:-*****
<mx:Button id="btn" label="Find Unmatch Nodes" width="221" height="30" click="select_tree()"/>
<mx:Tree id="tree" right="10" top="54" bottom="10" width="49.5%" dataProvider="{XMLList}"
fontFamily="Verdana" fontSize="11" showScrollTips="true"
allowMultipleSelection="true"
alternatingItemColors="[#F5F5F5]"
labelField="@label" selectionColor="#ECF335" showRoot="false"/>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通过将 tree.selectedIndices 设置为 allItems1 (而不是 allItems),您的代码中有一个错误。
为什么不直接创建一个 Bindable 数组,并将其设置为树的 selectedIndices 属性?
即
最后,跟踪它,而不必手动完成? Flex 的优点之一是能够利用 Binding 值。
You have a mistake in your code by setting tree.selectedIndices to allItems1 (instead of allItems).
Why don't you just created a Bindable Array, and have it set to the selectedIndices property of the tree?
i.e.
Finally, trace that out, instead of having to do it manually? One of the beauties of Flex is being able to leverage Binding values.