Coolite TreePanel 操作之一:TreePanel 刷新
2011-10-22 19:53
344 查看
脚本:
Coolite.AjaxMethods.RefreshMenu方法:
脚本注册:
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));
相关文章推荐
- Coolite TreePanel 操作之一:TreePanel 刷新
- coolite treepanel增删改并自动刷新
- Coolite TreePanel的数据绑定操作
- Coolite TreePanel 静态刷新
- coolite有关 Treepanel 节点问题
- TreePanel 操作之一:加载树
- [coolite] TreePanel CheckBox联动
- [coolite] TreePanel CheckBox联动
- Coolite TreePanel开发实例
- Coolite之TreePanel右键功能菜单
- Extjs TabPanel Tab页面刷新操作
- 解决了coolite官方示例"TreePanel/basic/refresh static tree"的一个错误
- ExtJs Treepanel刷新树形菜单
- 【转载】Coolite之TreePanel右键功能菜单
- Extjs4之 treepanel 操作
- Coolite TreePanel开发实例 包括功能(右击菜单,筛选菜单,拖动菜单)
- Extjs 3 TreePanel相关操作
- Coolite GridPanel 操作之一:获取gridpanel 选中行的记录信息
- extjs4 treepanel、 树、节点的操作
- UpdatePanel GridView 无刷新操作