TREE GRID ICONS

1. Icons: How do I incooperate icons into my treeview menu below? The kind of icons am looking for is the one in the screenshot that preceeds this one. (NB: I am using xml as my datasource for the nodes, and am developing with visual basic)



2. How can I get the DataFile="" from my vb code to fill my treeview menu? see sample code below

<div>
       <asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="../App_Data/TreeViewXML.xml"></asp:XmlDataSource>
</div>

3. How do I make this node item become a clickable link? i.e. when I click i want it to open a modal window....


<Node Text="Time Attendance" Expanded="True" Url="#">
        <Item Text="Program" Url="#"></Item>
</Node>


3 Replies 1 reply marked as answer

MK Muthukrishnan Kandasamy Syncfusion Team June 18, 2020 04:40 PM UTC

 
Thanks for contacting Syncfusion support. 
 
Query 1: Icons: How do I incooperate icons into my treeview menu below? 
 
Since, we haven’t provided support for SpriteCss field property in XML data source. We have considered your requirement as feature from Syncfusion TreeView control. This feature will be included in the anyone of our upcoming release. 
 
Generally, we will plan the feature implementation based on feature rank, Wishlist plan and customer request count for some feature. 
 
You can track the status through the below portal link. 
 
 
Query 2: How can I get the DataFile="" from my vb code to fill my treeview menu? 
 
Yes, we can load XML data into TreeView control by using DataSourceID. We can load the XML data by setting relative path for DataFile. Please refer the below code block. 
 
    <ej:TreeView 
            ID="TreeXmlDS" 
            runat="server" 
            DataSourceID="XmlDataSource1"> 
     </ej:TreeView> 
     <asp:XmlDataSource 
                ID="XmlDataSource1" 
                runat="server" 
                DataFile="~\App_Data\XMLData.xml"> 
            </asp:XmlDataSource> 
 
 
Query 3: How do I make this node item become a clickable link? 
 
Yes, we can use NavigateUrl property for making Tree Node as link. When we click the tree node it will redirect to that corresponding page. Please refer the code block. 
 
[XMLData.xml] 
 
  <Node Text="Time Attendance" Value="true" NavigateUrl="/About"> 
    <Item Text="Program" Url="#"></Item> 
  </Node> 
 
Please let us know, if you need any further assistance. 
 
Regards, 
Muthukrishnan K 


Marked as answer

JK Joji Kaju June 19, 2020 08:27 AM UTC

Thank you for your reply :)

So since I still want to have icons in my treeView, I came up with this code below, BUT I still can't get the icon displayed and the navigateUrl is also not working... could there be anything that I am missing?

NB: The 'mailicons.png' and other images are located in the same directory as the default.aspx file (for convenience' sake)


Visual Basic: (see highlighted code)

Private Sub LoadTreeView()
        treeData.Add(New LoadData With {.MenuNo = 1, .ParentId = 0, .Description = "Operator: ADMIN", .MenuModule = "", .MenuProgram = "", .SpriteCssClass = "mailicon sprite-folder", .Expanded = True})
        treeData.Add(New LoadData With {.MenuNo = 2, .ParentId = 1, .Description = "Manager Self Service", .MenuModule = "", .MenuProgram = "", .navigateUrl = "", .SpriteCssClass = "", .Expanded = False})
        treeData.Add(New LoadData With {.MenuNo = 3, .ParentId = 1, .Description = "Employee Self Service", .MenuModule = "", .MenuProgram = "", .navigateUrl = "", .SpriteCssClass = "", .Expanded = False})
        treeData.Add(New LoadData With {.MenuNo = 4, .ParentId = 2, .Description = "Human Reasources", .MenuModule = "", .MenuProgram = "", .navigateUrl = "", .SpriteCssClass = "", .Expanded = False})
        treeData.Add(New LoadData With {.MenuNo = 5, .ParentId = 4, .Description = "Leave Management", .MenuModule = "", .MenuProgram = "", .navigateUrl = "", .SpriteCssClass = "", .Expanded = False})
        treeData.Add(New LoadData With {.MenuNo = 6, .ParentId = 5, .Description = "Leave Mgt", .MenuModule = "", .MenuProgram = "", .navigateUrl = "https://www.google.com",  .SpriteCssClass = "mailicon sprite-folder", .Expanded = False})
        treeData.Add(New LoadData With {.MenuNo = 7, .ParentId = 2, .Description = "Payroll", .MenuModule = "", .MenuProgram = "", .navigateUrl = "", .SpriteCssClass = "", .Expanded = False})
        treeData.Add(New LoadData With {.MenuNo = 8, .ParentId = 7, .Description = "Utilities", .MenuModule = "", .MenuProgram = "", .navigateUrl = "", .SpriteCssClass = "", .Expanded = False})
        treeData.Add(New LoadData With {.MenuNo = 9, .ParentId = 8, .Description = "Transaction Utilities", .MenuModule = "", .MenuProgram = "", .navigateUrl = "", .SpriteCssClass = "", .Expanded = False})
        treeData.Add(New LoadData With {.MenuNo = 10, .ParentId = 8, .Description = "Loan Utilities", .MenuModule = "", .MenuProgram = "PYLOAN_UTILITY", .navigateUrl = "", .SpriteCssClass = "", .Expanded = False})
        Me.treeview.DataSource = treeData
    End Sub

    Public Class LoadData
        Public Property MenuNo As String
        Public Property ParentId As String
        Public Property Description As String
        Public Property MenuModule As String
        Public Property MenuProgram As String
        Public Property navigateUrl As String
        Public Property SpriteCssClass As String
        Public Property Expanded As Boolean
    End Class


default.aspx:

<ej:TreeView Font-Size="10px"
                            ID="treeview"
                            runat="server"
                            DataTextField="Description"
                            DataIdField="MenuNo"
                            DataParentIdField="ParentId"
                            DataSpriteCssField="SpriteCssClass"
                            DataExpandedField="Expanded">
 </ej:TreeView>

CSS:
    <style>
        .darktheme .cols-sample-area .mailicon, .darktheme .cols-sample-area .e-node-hover .mailicon, .darktheme .cols-sample-area .e-node-focus.e-active .mailicon {
            background-image: url("mailicons.png");
        }

        .cols-sample-area .e-active .mailicon {
            background-image: url("mailicons.png");
        }

        .cols-sample-area .mailicon, .cols-sample-area .e-editable .mailicon, .cols-sample-area .e-node-hover .mailicon, .cols-sample-area .e-node-focus.e-active .mailicon {
            background-image: url("mailicons.png");
        }

        .material .cols-sample-area .mailicon, .material .cols-sample-area .e-editable .mailicon, .material .cols-sample-area .e-node-hover .mailicon, .material .cols-sample-area .e-node-focus.e-active .mailicon {
            background-image: url("mailicons.png");
        }
        .office-365 .cols-sample-area .e-active .mailicon {
            background-image: url("mailicons.png");
        }

        .mailicon {
            display: inline-block;
            overflow: hidden;
            background-repeat: no-repeat;
            text-align: center;
            vertical-align: middle;
            width: 20px;
            height: 18px;
        }

        .sprite-calendar {
            background-position: -25px -255px;
        }

        .sprite-contacts {
            background-position: -26px -429px;
        }

        .sprite-deleted {
            background-position: -24px -152px;
        }

        .sprite-drafts {
            background-position: -24px -83px;
        }

        .sprite-folder {
            background-position: -24px -464px;
        }

        .sprite-folders {
            background-position: -24px -222px;
        }

        .sprite-inbox {
            background-position: -25px -13px;
        }

        .sprite-junk {
            background-position: -23px -187px;
        }

        .sprite-notes {
            background-position: -26px -394px;
        }

        .sprite-outbox {
            background-position: 0 -414px;
            width: 16px;
            height: 16px;
        }

        .sprite-root {
            background-position: -25px -49px;
        }

        .sprite-sentitems {
            background-position: -26px -118px;
        }
    </style>


MK Muthukrishnan Kandasamy Syncfusion Team June 23, 2020 05:16 AM UTC

 
Hi Joji, 
 
Thanks for the update. 
 
We have validated your reported problem in TreeView control. We suspect that you have not added style properly. We have prepared sample to meet your requirement, in this sample we have loaded icons for some tree nodes using spriteCssclass. For NavigationUrl property you have used value as string type, but we need assign value as object type for this property. Please refer the below code block. 
 
[Default.aspx.vb] 
 
treeData.Add(New LoadData With {.MenuNo = 1, .ParentId = 0, .Description = "Operator: ADMIN", .MenuModule = "", .MenuProgram = "", .navigateUrl = New Dictionary(Of String, String) From {{"target", "_blank"}, {"rel='nofollow' href", "https://www.google.com"}}, .SpriteCssClass = "mailicon sprite-folder", .Expanded = True}) 
 
 
We have attached sample for your convenience, which can be downloaded from the below link. 
 
 
Please check the output screenshot of the attached sample. 
 
 
 
 
Please let us know, if you need any further assistance. 
 
Regards, 
Muthukrishnan K 


Loader.
Up arrow icon