首页 > 代码库 > Ext.Net TreePanel 修改Icon图标
Ext.Net TreePanel 修改Icon图标
分类: Ext.Net2012-09-24 13:44 1779人阅读 评论(0) 收藏 举报
webformserverextassemblyxhtmlobject
1、默认icon
2、自定义icon
完整的代码,文件WebForm2.aspx中代码
[html] view plaincopy
- <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="ext_SMS.WebForm2" %>
- <%@ Import Namespace="System.Collections.Generic" %>
- <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head id="Head1" runat="server">
- <title>改变TreePanel Icon图标</title>
- style type="text/css"> //自定义样式
- .add {
- background-image: url(image/query.jpg) !important;
- }
- </style>
- </head>
- <body>
- <form id="Form2" runat="server">
- <ext:ResourceManager ID="ResourceManager1" runat="server" />
- <ext:Viewport ID="Viewport1" runat="server">
- <Items>
- <ext:BorderLayout ID="BorderLayout1" runat="server">
- <West>
- <ext:TreePanel
- ID="TreePanel1"
- runat="server"
- Title="Tree"
- Width="200"
- AutoHeight="true"
- Border="false">
- <Root>
- <ext:AsyncTreeNode Text="系统功能模块" NodeID="root" Expanded="true" Icon="ApplicationHome">
- </ext:AsyncTreeNode>
- </Root>
- <Loader>
- <ext:PageTreeLoader RequestMethod="POST" OnNodeLoad="GetReportList" PreloadChildren="true">
- <EventMask ShowMask="true" Target="Parent" Msg="Loading..." />
- </ext:PageTreeLoader>
- </Loader>
- <Listeners>
- <Click Handler="if(node.isLeaf()){e.stopEvent();loadExample(node);}" />
- </Listeners>
- </ext:TreePanel>
- </West>
- <Center>
- <ext:TabPanel ID="Pages" runat="server" EnableTabScroll="true" />
- </Center>
- </ext:BorderLayout>
- </Items>
- </ext:Viewport>
- </form>
- </body>
- </html>
后台文件WebForm2.aspx.cs中代码:
[csharp] view plaincopy
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using Ext.Net;
- using System.Data;
- namespace ext_SMS
- {
- public partial class WebForm2 : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- }
- protected void GetReportList(object sender, NodeLoadEventArgs e)
- {
- string prefix = e.ExtraParams["prefix"] ?? "";
- if (!string.IsNullOrEmpty(e.NodeID))
- {
- for (int i = 1; i < 6; i++)
- {
- AsyncTreeNode asyncNode = new AsyncTreeNode();
- asyncNode.Text = prefix + e.NodeID + i;
- asyncNode.NodeID = e.NodeID + i;
- e.Nodes.Add(asyncNode);
- }
- for (int i = 6; i < 11; i++)
- {
- Ext.Net.TreeNode treeNode = new Ext.Net.TreeNode();
- treeNode.Text = prefix + e.NodeID + i;
- treeNode.NodeID = e.NodeID + i;
- treeNode.Leaf = true;
- // treeNode.Icon = Icon.Accept; //注意此处设置不起作用
- treeNode.IconCls = "add"; //设置自定义样式
- e.Nodes.Add(treeNode);
- }
- }
- }
- }
- }
注意:图片位于image文件夹下,名称query.jpg
3、需要默认样式时,不设置自定义样式即可。
去掉这句:treeNode.IconCls = "add"; //设置自定义样式
Ext.Net TreePanel 修改Icon图标
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。