[Ext.Net]TreePanel自定义图标

<head id="Head1" runat="server">
  <title>改变TreePanel Icon图标</title>
  <style type="text/css">   
   .add {
      background-image: url(../../Icon/user.gif) !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>
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);
            }
        }
    }


[Ext.Net]TreePanel自定义图标_第1张图片
   

你可能感兴趣的:([Ext.Net]TreePanel自定义图标)