Coolite TreePanel 작업 중 하나: TreePanel 새로 고침

5656 단어 TreePanel
스크립트:
function refreshTree(tree) {

            tree.el.mask('Loading...', 'x-loading-mask');

            Coolite.AjaxMethods.RefreshMenu({

                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', ' ');



                }



            });

        }


 
Coolite.AjaxMethods.RefreshMenu 방법:
 /// <summary>

        ///   Json  

        /// </summary>

        /// <returns></returns>

        [AjaxMethod]

        public string RefreshMenu()

        {

            Coolite.Ext.Web.TreeNodeCollection nodes = LoadTree(this.TreePanelOrganization.Root);

            return nodes.ToJson();

        }



 



 



   /// <summary>

        ///  、  //WCF entity framework  

        /// </summary>

        /// <param name="nodes"></param>

        /// <returns>TreeNodeCollection</returns>

        private Coolite.Ext.Web.TreeNodeCollection LoadTree(Coolite.Ext.Web.TreeNodeCollection nodes)

        {



           

            if (nodes == null)

            {

                nodes = new Coolite.Ext.Web.TreeNodeCollection();

            }// null 



            TreePanelOrganization.Root.Clear();



            Coolite.Ext.Web.TreeNode node = new Coolite.Ext.Web.TreeNode("Hisoft", "Hisoft", Icon.Group);

            node.Qtip = "Hisoft";

            nodes.Add(node);

            node.Expanded = true;



            // OrganizationService.OrganizationServiceClient client = new PMS.Web.Admin.OrganizationService.OrganizationServiceClient();

            //  client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;



            // 

            DCC_ResorganizationList organizationlist = client.GetOrganizationList("");



            foreach (var superCode in organizationlist.ToList())

            {

                Coolite.Ext.Web.TreeNode supernode = new Coolite.Ext.Web.TreeNode();

                string parentcode = superCode.OrganizationCode;

                supernode.NodeID = superCode.OrganizationCode;

                supernode.Text = superCode.OrganizationName;

                supernode.Qtip = superCode.OrganizationFullName;

                supernode.Cls = superCode.OrganizationID;

                //supernode.Expanded = true;

                supernode.Icon = Icon.GroupKey;

                //supernode.CustomAttributes.Add(new ConfigItem(

                node.Nodes.Add(supernode);

                LoadOrgRoleByOrganizationID(superCode.OrganizationID, supernode);

                CreateCycleTree(parentcode, supernode);

            }



            return nodes;



            //linq to sql class  

            //IList<RES_Organization> OrgSuperDepartment = OrgData.GetCycleOrganization("", context);

            //foreach (var superCode in OrgSuperDepartment)

            //{

            //    Coolite.Ext.Web.TreeNode supernode = new Coolite.Ext.Web.TreeNode();

            //    supernode.NodeID = superCode.organization_code;

            //    supernode.Text = superCode.organization_name;

            //    supernode.Qtip = superCode.organization_full_name;

            //    supernode.Icon = Icon.GroupKey;

            //    node.Nodes.Add(supernode);

            //    CreateCycleTree(supernode.NodeID, supernode);



            //}

           

        }





        /// <summary>

        ///  

        /// </summary>

        /// <param name="code"> code</param>

        /// <param name="parentcode"> </param>

        private void CreateCycleTree(string code, Coolite.Ext.Web.TreeNode parentcode)

        {

            // OrganizationService.OrganizationServiceClient client = new PMS.Web.Admin.OrganizationService.OrganizationServiceClient();



            // ID 

            DCC_ResorganizationList orgDepartment = client.GetOrganizationList(code);



            // IList<RES_Organization> orgDepartment = OrgData.GetCycleOrganization(code, context);



            foreach (var org in orgDepartment.ToList())

            {

                Coolite.Ext.Web.TreeNode node = new Coolite.Ext.Web.TreeNode();

                string orgparentcode = org.OrganizationCode;

                node.NodeID = org.OrganizationCode;

                node.Text = org.OrganizationName;

                node.Qtip = org.OrganizationFullName;

                node.Cls = org.OrganizationID;

                node.Icon = Icon.GroupGo;

                parentcode.Nodes.Add(node);

                LoadOrgRoleByOrganizationID(org.OrganizationID, node);

                CreateCycleTree(orgparentcode, node);

            }



        }


 
 
스크립트 등록:
  string JsFunction = "refreshTree(#{TreePanelOrganization})";

                //string JsFunction = "alert('dd');";

                //string JsFunction = "refreshTree()";

                Coolite.Ext.Web.ScriptManager sm = Coolite.Ext.Web.ScriptManager.GetInstance(HttpContext.Current);

                sm.AddScript(string.Format("{0};", JsFunction));


 

좋은 웹페이지 즐겨찾기