首页 > 代码库 > ext:TreePanel 动态添加和单击事件
ext:TreePanel 动态添加和单击事件
<ext:TreePanel ID="UserTreePanel" runat="server" Title="用户结构图" AutoHeight="true" Border="false"> <Listeners> <BeforeLoad Fn="nodeLoad" /> <Click Handler="clickTree1(node);" /> </Listeners> </ext:TreePanel>
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | <ext:XScript ID= "XScript1" runat= "server" > <script> var nodeLoad = function (node) { #{DirectMethods}.NodeLoad(node.id, { success: function (result) { var data = http://www.mamicode.com/eval( "(" + result + ")" ); node.loadNodes(data); }, failure: function (errorMsg) { Ext.Msg.alert( ‘Failure‘ , errorMsg); } }); } var clickTree1 = function (node) { #{DirectMethods}.ClickTree(node.id); } </script> </ext:XScript> |
[DirectMethod] public string NodeLoad(string nodeID) { Ext.Net.TreeNodeCollection nodes = new Ext.Net.TreeNodeCollection(); if (!string.IsNullOrEmpty(nodeID)) { List<sp_GetUserByReferee_Result> list = _edm.sp_GetUserByReferee(nodeID).ToList(); foreach (var item in list) { AsyncTreeNode asyncNode = new AsyncTreeNode(); asyncNode.Text = item.User_DisplayName; asyncNode.NodeID = item.User_Name; asyncNode.Icon = Icon.User; nodes.Add(asyncNode); } } return nodes.ToJson(); } [DirectMethod] public void ClickTree(string nodeID) { if (!string.IsNullOrEmpty(nodeID)) { XF_User user = _edm.XF_User.First(c => c.User_Name == nodeID); ucEdit.LoadData(user.Id); ucEdit.Show(); } }
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。