`
luhantu
  • 浏览: 203055 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

自动打开Tree节点并定位(Opening nodes in a Flex Tree)

    博客分类:
  • Flex
阅读更多

Flex Tree 中有可以用程序打开根节点并定位到字节点的操作,那么有expandItem & scrollToIndex 两个方法就很有用。

1.expandItem 是Tree 和 AdvancedDatagrid特有的属性,就是打开或关闭导航树的分支节点。

2.scrollToIndex是listClasses 和 AdvancedListBase 类特有的属性,确保给定索引处的数据提供程序项目可见。

3.isItemOpen 是listClasses 和 AdvancedListBase 类特有的属性,如果指定的分支节点处于打开状态,则返回 true

<?xml version="1.0" encoding="utf-8"?>
<s:VGroup xmlns:fx="http://ns.adobe.com/mxml/2009" 
		  xmlns:s="library://ns.adobe.com/flex/spark" 
		  xmlns:mx="library://ns.adobe.com/flex/mx" width="100%" height="100%">
	<fx:Declarations>
		<fx:XMLList id="treeData">
			<node label="Mail Box">
				<node label="Inbox">
					<node label="Marketing"/>
					<node label="Product Management"/>
					<node label="Personal"/>
				</node>
				<node label="Outbox">
					<node label="Professional"/>
					<node label="Personal"/>
				</node>
				<node label="Spam"/>
				<node label="Sent"/>
			</node>
		</fx:XMLList>
	</fx:Declarations>
	<fx:Script>
		<![CDATA[
			 import mx.events.ListEvent;
			private function comboBox_change(evt:ListEvent):void 
			{
				var team:String = ComboBox(evt.currentTarget).selectedItem.@label;
				var node:XMLList = treeData.node.node.(@label == team);
				expandParents(node[0]);
				tree.selectedItem = node[0];
				var idx:int = tree.getItemIndex(node[0]);
				tree.scrollToIndex(idx);
			}
			
			private function expandParents(node:XML):void 
			{
				if (node && !tree.isItemOpen(node)) {
					tree.expandItem(node, true);
					expandParents(node.parent());
				}
			}
		]]>
	</fx:Script>
	<mx:ComboBox id="comboBox"
				 prompt="Please select a team..."
				 dataProvider="{treeData.node.node}"
				 labelField="@label"
				 change="comboBox_change(event);"/>
	<mx:Tree id="tree"
			 dataProvider="{treeData}"
			 labelField="@label"
			 showRoot="false"
			 width="300"
			 rowCount="8" />
</s:VGroup>
 
分享到:
评论

相关推荐

    echarts tree 点击节点收缩(关闭子节点)功能实现

    在本文中,我们将深入探讨如何在ECharts库中实现一个具有点击节点收缩(关闭子节点)功能的树形图表(Tree)。ECharts是一款基于JavaScript的数据可视化库,它提供了丰富的图表类型,包括柱状图、折线图、饼图以及...

    tree节点移动 Tree节点移动到DataGrid Winfrom 皮肤

    在本项目中,我们讨论的是如何实现`TreeNodes`在`TreeView`中的移动,并将这些节点的数据同步显示到`DataGridView`中,同时考虑到了自定义窗体的皮肤设置。 首先,我们要理解`TreeNodes`的移动操作。在C#中,可以...

    layui-tree实现Ajax异步请求后动态添加节点的方法

    在本示例中,我们需要实现一个功能:当用户在树形菜单中选择某一节点时,通过 AJAX 异步请求向后台添加新的子节点,并在前端动态显示出来。 首先,我们看到 HTML 结构中有一个 `#demo` ID 的 `ul` 元素,它是 layui...

    treeview中只能打开一个节点

    For Each node In TreeView1.Nodes If node.IsExpanded And node IsNot e.Node Then ' 如果有,就将其折叠 node.Collapse() End If Next End Sub ``` 这段代码会遍历TreeView的所有节点,如果找到一个已展开...

    jsTree动态tree

    jsTree支持动态加载数据,这意味着当用户展开一个节点时,其子节点才会被请求并显示。这种机制可以提高页面加载速度,特别是在处理大量数据时。动态加载通常与服务器端接口结合使用,通过Ajax请求获取子节点数据。 ...

    alvtree完全展开合并讲解.docx

    对于完全展开的实现,我们需要遍历 ALVTREE 的所有节点,并逐个展开它们。在这个过程中,有两个关键点需要注意: 1. 调用 `expand_nodes` 方法展开节点时,需要确保该节点确实存在子节点。错误的做法是在每次添加...

    Skewness-aware clustering tree for unevenly distributed spatial sensor nodes in smart city

    To address this challenge, this paper proposes a novel skewness-aware clustering tree (SWC-tree) by clustering sensor nodes. Sensor nodes in a dense region will be put into the sam

    jsTree中文文档

    除了事件,还可以直接调用jsTree的方法,如打开、关闭节点,获取选中节点等: ```javascript // 打开节点 $('#jstree_demo_div').jstree('open_node', '#node_id'); // 关闭节点 $('#jstree_demo_div').jstree('...

    带复选框的多级目录树,复选框的选择控制子节点父节点 全选和反选

    4. **控制父节点(Controlling Parent Nodes)**: 当用户勾选或取消一个子节点的复选框时,我们需要判断该操作是否会影响父节点的状态。如果一个父节点的所有子节点都已被选中,那么父节点也应该被选中;反之,...

    C# Winform Tree 使用示例

    treeView1.Nodes.Sort((a, b) =&gt; a.Text.CompareTo(b.Text)); treeView1.EndUpdate(); ``` - 如果需要更复杂的排序逻辑,可以创建自定义比较器。 7. **数据库集成** - 提供的"dbo.sql"可能包含了数据库表结构...

    wsn-topology.zip_wsn nodes_wsn节点分布_网络拓扑_节点分布_节点随机

    无线传感器网络(Wireless Sensor Networks, WSN)是由大量小型、低功耗的传感器节点组成的分布式网络,这些节点能够感知环境、收集数据并进行通信。标题"wsn-topology.zip_wsn nodes_wsn节点分布_网络拓扑_节点分布...

    java tree的实现

    - **添加子节点**:通过 `addChildNode(TreeNode treeNode)` 方法向当前节点添加子节点,并自动设置子节点的父节点为当前节点。 #### 五、具体实现细节 1. **Tree 类实现** - **根节点的管理**:每个树都有一个...

    This code can as many child nodes to a tree view control and

    This code can as many child nodes to a tree view control and can save the data and structure of the treeview control in a text file. Later the data and structure can be retrieved from the text file ...

    jsTree实例,jsTree实例

    1. **节点 (Nodes)**:jsTree 中的基本元素,可以是树的根节点或子节点。每个节点包含文本、ID、图标等属性,并可拥有子节点。 2. **容器 (Container)**:通常是一个 HTML 元素,如 `div`,用于承载整个树结构。 3...

    JsTree 最详细教程及完整实例

    1. **节点(Nodes)**:在 JsTree 中,每个元素都被称为一个节点。节点可以有父节点和子节点,形成层级关系。 2. **配置(Configuration)**:JsTree 提供了大量的配置选项,允许用户定制其行为和外观。例如,你...

    java 实现动态改变树形结构中主节点的名称

    树形结构由根节点(root node)、中间节点(intermediate nodes)以及叶子节点(leaf nodes)组成。 ### 二、构建树形结构 #### 1. 创建节点 通过`DefaultMutableTreeNode`类创建节点,并将其添加到父节点中。 ```...

    Easyui tree 测试demo

    在 Tree 应用中,这些数据会被读取并转化为 Tree 节点。脚本可能包含创建数据表的语句(如 `CREATE TABLE`),以及插入数据的语句(如 `INSERT INTO`)。 总结起来,这个测试 demo 展示了如何使用 EasyUI Tree 组件...

    ztree根据文本内筛选叶子节,并改变叶子节点字体颜色

    本主题聚焦于如何利用ZTree实现基于文本内容筛选并改变叶子节点的字体颜色。这个功能在数据展示和用户交互中具有较高的实用价值,比如在搜索或过滤功能中。 首先,我们需要理解ZTree的核心概念。ZTree是由JSON数据...

    EasyUI实现异步加载tree(整合Struts2)源码

    如果一切配置正确,当你展开Tree节点时,将动态加载并显示子节点。如果遇到问题,可以参照提供的博客链接(http://blog.csdn.net/itmyhome1990/article/details/38818449)或者EasyUI和Struts2的官方文档进行排查。 ...

    java-leetcode题解之All Nodes Distance K in Binary Tree.java

    java基础 java_leetcode题解之All Nodes Distance K in Binary Tree.java

Global site tag (gtag.js) - Google Analytics