标签:
1 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MainForm.aspx.cs" Inherits="WebEXT.MainForm" %> 2 3 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 4 <html xmlns="http://www.w3.org/1999/xhtml"> 5 <head runat="server"> 6 <title>管理系统</title> 7 </head> 8 <script type="text/javascript"> 9 var addTab = function (tabPanel, id, url, title) { 10 var tab = tabPanel.getComponent(id); 11 var url = url.replace(‘#‘,‘‘); 12 if (!tab) { 13 tab = tabPanel.add({ 14 id: id, 15 title: title, 16 closable: true, 17 autoLoad: { 18 showMask: true, 19 url: url, 20 mode: "iframe", 21 maskMsg: "Loading " + url + "..." 22 } 23 }); 24 } 25 26 tabPanel.setActiveTab(tab); 27 } 28 </script> 29 <body> 30 <form id="form1" runat="server"> 31 <div> 32 <ext:ResourceManager ID="ResourceManager1" runat="server"> 33 </ext:ResourceManager> 34 <ext:Viewport ID="Viewport" runat="server" Layout="BorderLayout"> 35 <Items> 36 <ext:TreePanel runat="server" ID="TreePanel1" Region="West" MinWidth="175" Width="250" 37 Title="系统功能目录" Split="true" Border="true"> 38 <Root> 39 <ext:Node Text="菜单" NodeID="-1" Expanded="True" Icon="ApplicationLink"> 40 </ext:Node> 41 </Root> 42 <BottomBar><ext:StatusBar ID="StatusBar1" runat="server" AutoClear="1500"></ext:StatusBar></BottomBar> 43 <Store> 44 <ext:TreeStore runat="server"> 45 <Proxy> 46 <ext:AjaxProxy Url="/tree-handler.ashx"> 47 </ext:AjaxProxy> 48 </Proxy> 49 </ext:TreeStore> 50 </Store> 51 <Listeners> 52 <ItemClick Handler="addTab(#{TabPanel1},‘tab‘+record.data.id, record.data.href,record.data.text);"> 53 </ItemClick> 54 </Listeners> 55 </ext:TreePanel> 56 <ext:TabPanel ID="TabPanel1" runat="server" Region="Center" ActiveTabIndex="0" Border="True" 57 Title="主界面" AutoScroll="True"> 58 <Items> 59 <ext:Panel ID="Test1" runat="server" Title="主页" Collapsed="false"> 60 </ext:Panel> 61 </Items> 62 </ext:TabPanel> 63 </Items> 64 </ext:Viewport> 65 </div> 66 </form> 67 </body> 68 </html>
异步加载树的代码:
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Web; 5 using Ext.Net; 6 7 namespace WebEXT 8 { 9 /// <summary> 10 /// tree_handler 的摘要说明 11 /// </summary> 12 public class tree_handler : IHttpHandler 13 { 14 15 public void ProcessRequest(HttpContext context) 16 { 17 //得到node id 18 string nodeId = context.Request["node"]; 19 20 SysMenuInfo sysMenuInfo = new SysMenuInfo(); 21 //根据node id 进行处理 22 NodeCollection nodes = new NodeCollection(); 23 IList<sysMenu> list = new List<sysMenu>(); 24 list = sysMenuInfo.GetChildMenu(nodeId); 25 foreach (var sysMenu in list) 26 { 27 nodes.Add(new Node() { Text = sysMenu.nvcMenuName, Icon = Icon.ApplicationLink, Href = "#"+sysMenu.nvcUrl,NodeID=sysMenu.nvcID}); 28 } 29 string responseString = nodes.ToJson(); 30 context.Response.Write(responseString); 31 context.Response.End(); 32 } 33 34 public bool IsReusable 35 { 36 get 37 { 38 return false; 39 } 40 } 41 } 42 }
标签:
原文地址:http://www.cnblogs.com/tangchun/p/4649440.html