add text label on nodes

3 posts, 0 answers
  1. Rubihno
    Rubihno avatar
    86 posts
    Member since:
    Jun 2008

    Posted 04 Dec 2008 Link to this post

    Hi,

    I populate my treeview to code behind, with sql tables, i would you like to add on nodes the label....

    For example

    - Users
      -   Andy (word)    <- nodes
      -   Micheal (word)  <- nodes

    The name of the node are in colum table, but the label (word) is not the db values, i would you like to add this label for example, when i generate the treeview....

    How i make? in code behind make this?
     
  2. Serrin
    Serrin avatar
    286 posts
    Member since:
    Sep 2008

    Posted 04 Dec 2008 Link to this post

    Hey Rubihno,

    Alright, two parts to this answer. :)

    First, you could modify the text as follows:

        protected void RadTreeView1_NodeCreated(object sender, Telerik.Web.UI.RadTreeNodeEventArgs e)  
        {  
           e.Node.Text = e.Node.Text + " (word)";  
        }  

    That works and puts (word) after all nodes...  The trick is...

    Second part, figuring out if the node is one that should get the (word)...  My first idea was to check level (aka, root is 0, everything else is a child of root:

            if (e.Node.Level > 0)  
            {  
                e.Node.Text = e.Node.Text + " (word)";  
            } 

    So you can play with e.Node to see if it fits some category... like maybe you have root/topics/kids, so then you would do if level > 1, etc.

    Let me know if this works for you! 

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Rubihno
    Rubihno avatar
    86 posts
    Member since:
    Jun 2008

    Posted 05 Dec 2008 Link to this post

    Thanks a lot, it is easy...:)


Back to Top