码迷,mamicode.com
首页 > 其他好文 > 详细

ext:TreePanel 动态添加和单击事件

时间:2014-05-28 01:18:27      阅读:532      评论:0      收藏:0      [点我收藏+]

标签:des   style   c   class   blog   code   

bubuko.com,布布扣
        <ext:TreePanel 
            ID="UserTreePanel" 
            runat="server" 
            Title="用户结构图" 
            AutoHeight="true" 
            Border="false"> 
            <Listeners>
                <BeforeLoad Fn="nodeLoad" />
                <Click Handler="clickTree1(node);" />
            </Listeners>
            
        </ext:TreePanel>  
bubuko.com,布布扣

 

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 = eval("(" + result + ")");
                    node.loadNodes(data);
                },
 
                failure: function (errorMsg) {
                    Ext.Msg.alert(‘Failure‘, errorMsg);
                }
            });
        }
        var clickTree1 = function (node) { 
            #{DirectMethods}.ClickTree(node.id);
         }
 
    </script>
</ext:XScript>

 

bubuko.com,布布扣
 [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(); 
            } 
        }
bubuko.com,布布扣

 

ext:TreePanel 动态添加和单击事件,布布扣,bubuko.com

ext:TreePanel 动态添加和单击事件

标签:des   style   c   class   blog   code   

原文地址:http://www.cnblogs.com/spencerai/p/3753854.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!