• TreePanel 操作之二:刷新TreePanel


         TreePanel的刷新,以下做为一个例子:

         当点击查询按钮时,TreePanel将重新刷新一次。

         前台代码:

    代码
    <ext:Button ID="ButtonQuery" runat="server" Text="Search" meta:resourcekey="ButtonQueryResource"
    StyleSpec
    ="padding-left:105px;">
    <Listeners>
    <Click Handler="Search(#{ClientJobTree});" />
    </Listeners>
    </ext:Button>

      脚本代码:

     

    代码
    function Search(tree) {
    Coolite.AjaxMethods.Query({
    success: function(result) {
    var nodes
    = eval(result);
    tree.root.ui.remove();
    tree.initChildren(nodes);
    tree.root.render();
    tree.el.unmask();
    },
    failure: function(msg) {
    tree.el.unmask();
    Ext.Msg.alert(
    'Failure', '未能加载数据');
    }
    });
    }

    后台代码:

      /// <summary>
            /// 绑定树
            /// </summary>
            public Coolite.Ext.Web.TreeNodeCollection TreeBind()
            {
                Coolite.Ext.Web.TreeNodeCollection nodes = new Coolite.Ext.Web.TreeNodeCollection();
                string projectID = Request.QueryString["ProjectID"].ToString();
                string name = TextFieldName.Text.ToString();
                string clientGroup = ComboBoxClientGroup.SelectedItem.Text.ToString();
                string services = ComboBoxClientService.SelectedItem.Text.ToString();
                Coolite.Ext.Web.TreeNode root = new Coolite.Ext.Web.TreeNode();
                //通过ProjectID找到Name
                PROJ_ProjectBase projectBase = this.logic.GetProjectBaseByProjectID(projectID);
                root.Text = projectBase.project_name;
                ClientJobTree.Root.Add(root);
                List<PROJ_ClientJob> rootList = this.logic.GetClientJob(projectID, name, services, clientGroup);
                foreach (PROJ_ClientJob item in rootList)
                {
                    string clientID = item.clientJob_id;
                    string clientName = item.job_name;
                    Coolite.Ext.Web.TreeNode supernode = new Coolite.Ext.Web.TreeNode();
                    supernode.NodeID = clientID;
                    supernode.Text = clientName;
                    supernode.Icon = Icon.Folder;
                    supernode.Expanded = true;
                    root.Nodes.Add(supernode);
                    this.NodeBind(clientID, supernode);
                }
    
                return ClientJobTree.Root;
            }
    
            /// <summary>
            /// 树节点的绑定
            /// </summary>
            /// <param name="parentNodeID">父节点号</param>
            /// <param name="parentcode">父节点</param>
            public void NodeBind(string parentNodeID, Coolite.Ext.Web.TreeNode parentcode)
            {
                string projectID = Request.QueryString["ProjectID"].ToString();
                List<PROJ_WBS> wbsList = this.logic.GetProjectWbsByClientJobID(parentNodeID, projectID);
                foreach (PROJ_WBS item in wbsList)
                {
                    Coolite.Ext.Web.TreeNode node = new Coolite.Ext.Web.TreeNode();
                    string wbsID = item.wbs_id;
                    node.NodeID = item.wbs_id;
                    node.Text = item.wbs_name;
                    node.Icon = Icon.Folder;
                    //node.Expanded = false;
                    parentcode.Nodes.Add(node);
                    this.NodeBind(wbsID, node);
                }
            }
    
    
            /// <summary>
            /// 查询事件
            /// </summary>
            [AjaxMethod]
            public string Query()
            {
                Coolite.Ext.Web.TreeNodeCollection nodes = this.TreeBind();
                return nodes.ToJson();
            }
    
  • 相关阅读:
    发现对各类项目有用的不同JavaScript的Web UI
    PowerDesigner 15.1 安装步骤详细图解及破解
    数据库设计工具PowerDesigner基础普及
    Vistual Studio 2010(VS2010)安装 MVC3.0具体方法
    pb的网络资源【转】
    powerbuider11 C/S 转换为B/S
    转:将可执行文件注册成系统windows服务
    WCF绑定类型选择(转)
    (转)找增强方法总结
    ALV简单模板1
  • 原文地址:https://www.cnblogs.com/mystar/p/1788585.html
Copyright © 2020-2023  润新知