<form id="form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server">
</ext:ResourceManager>
<ext:Viewport ID="Viewport1" runat="server" Layout="border">
<Items>
<ext:Panel ID="Panel1" runat="server" Height="60" Region="North" >
<Content>
<table width="100%" border="0" id="header" bgcolor="#fefb86" cellpadding="0" cellspacing="0">
<tr>
<td align="left">
<img src="Images/banner1.jpg" alt=""/ ></td>
<td align="right" valign="bottom" style=" font-size:12px; text-align: right;">
<span>
<image src="images/user.png" /><%=username%>
<image src="images/timer.png" width="14" height="16"/> <%=sj%>
<ext:ImageButton ID="ImageButton_Logout" runat="server" ImageUrl="Images/exit.gif" >
<DirectEvents>
<Click OnEvent="Button_Logout_Click">
<Confirmation ConfirmRequest="True" Title="确认登出" Message="您确定登出本系统吗?" />
</Click>
</DirectEvents>
<ToolTips>
<ext:ToolTip ID="ToolTip1" runat="server" Title="退出系统" Cls="tooltip1" />
</ToolTips>
</ext:ImageButton></span>
</td>
<td align="right">
<img src="images/banner2.jpg" alt=""/></td>
</tr>
</table>
</Content>
</ext:Panel>
<ext:TreePanel runat="server"
ID="TreePanel1"
Region="West"
Width="200"
Title="菜单列表"
Icon="ChartOrganisation">
<Listeners>
<ItemClick Handler="if (record.data.href) { e.stopEvent(); loadPage(#{Pages}, record); }" />
</Listeners>
</ext:TreePanel>
<ext:TabPanel
ID="Pages"
runat="server"
Region="Center"
EnableTabScroll="true"
LayoutOnTabChange="true"
/>
</Items>
</ext:Viewport>
</form>
<script type="text/javascript">
var loadPage = function (tabPanel, record) {
var tab = tabPanel.getComponent(record.getId());
if (!tab) {
tab = tabPanel.add({
id: record.getId(),
title: record.data.text,
closable: true,
loader: {
url: record.data.href,
renderer: "frame",
loadMask: {
showMask: true,
msg: "Loading " + record.data.text + "页面"
}
},
autoScroll: true
});
}
tabPanel.setActiveTab(tab);
};
</script>
一个根节点
Node node = new Node();
node.Text = "所有菜单";
TreePanel1.Root.Add(node);
BindTreeView(node, "", dtAll);
下面都是子节点,
protected void BindTreeView(Node treeNode, string parentID, DataTable dtAll)
{
Node fnode;
DataRow[] drs = dtAll.Select("fatherID='" + parentID + "'", "menuID");
{
foreach(DataRow dr in drs)
{
//判断如果url为空-->跟节点继续
if ( dr["url"].ToString() == "")
{
fnode = new Node();
fnode.Text = dr["menuName"].ToString().Trim();
fnode.NodeID = string.Concat("Node_", dr["menuID"].ToString().Trim());
fnode.Leaf = false;
treeNode.Children.Add(fnode);
BindTreeView(fnode, dr["menuid"].ToString(), dtAll);
}
else
{
Node node01 = new Node();
node01.Text = dr["menuName"].ToString().Trim();
node01.NodeID = string.Concat("Node_", dr["menuID"].ToString().Trim());
node01.Leaf = true;
node01.Href = dr["url"].ToString().Trim();
treeNode.Children.Add(node01);
}
}
}
}
这样,左边是一个treeview样式,但是父节点下也必须有子节点,否则会弹出一个框。