Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4034914
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:01:56+00:00 2026-05-20T12:01:56+00:00

I am using the teleriks treeview control (asp.net mvc extensions), where I may have

  • 0

I am using the teleriks treeview control (asp.net mvc extensions), where I may have up to three children nodes, like so (drumroll…… awesome diagram below):

it has its own formatting, looking a bit like this:

<%= 
    Html.Telerik().TreeView()
        .Name("TreeView")
        .BindTo(Model, mappings =>
                           {
                               mappings.For<Node1>(binding => binding
                                                                     .ItemDataBound((item, Node1) =>
                                                                                        {
                                                                                            item.Text = Node1.Property1;
                                                                                            item.Value = Node1.ID.ToString();
                                                                                        })
                                                                     .Children(Node1 => Node1.AssocProperty));

                               mappings.For<Node2>(binding => binding
                                                                         .ItemDataBound((item, Node2) =>
                                                                                            {
                                                                                                item.Text = Node2.Property1;
                                                                                                item.Value = Node2.ID.ToString();
                                                                                            })
                                                                         .Children(Node2 => Node2.AssocProperty));

                               mappings.For<Node3>(binding => binding
                                                                  .ItemDataBound((item, Node3) =>
                                                                                     {
                                                                                         item.Text = Node3.Property1;
                                                                                         item.Value = Node3.ID.ToString();
                                                                                     }));
                           })
 %> 

which causes it to render like this. I find it unsual that when I set the value it is rendered in a hidden input ? But anyway:…

<li class="t-item">
<div class="t-mid">
    <span class="t-icon t-plus"></span>
    <span class="t-in">Node 1</span>
    <input class="t-input" name="itemValue" type="hidden" value="6" /></div>

        <ul class="t-group" style="display:none">
            <li class="t-item t-last">
                <div class="t-top t-bot">
                    <span class="t-icon t-plus"></span>
                    <span class="t-in">Node 1.1</span>
                    <input class="t-input" name="itemValue" type="hidden" value="207" />
                </div>

                    <ul class="t-group" style="display:none">
                        <li class="t-item">
                            <div class="t-top">
                                <span class="t-in">Node 1.1.1</span>
                                <input class="t-input" name="itemValue" type="hidden" value="1452" />
                            </div>
                        </li>

                        <li class="t-item t-last">
                            <div class="t-bot">
                                <span class="t-in">Node 1.1.2</span>
                                <input class="t-input" name="itemValue" type="hidden" value="1453" />
                            </div>
                        </li>
                    </ul>
            </li>
        </ul>

What I am doing is updating a div after the user clicks on a certain node. But when the user clicks on a node, I want to send the ID not the Node text property. Which means I have to get it out of the value in these type lines <input class="t-input" name="itemValue" type="hidden" value="1453" />, but it can be nested differently each time, so the existing code I ahve doesn’t ALWAYS work:

<script type="text/javascript">

    function TreeView_onSelect(e) {
    //`this` is the DOM element of the treeview
        var treeview = $(this).data('tTreeView');

        var nodeElement = e.item;
    var id = e.item.children[0].children[2].value;


...

</script>

So based on that, what is a better way to get the appropriate id each time with javascript/jquery?

edit:

Sorry to clarify a few things

1) Yes, I am handling clicks to the lis of the tree & want to find the value of the nested hidden input field. As you can see, from the telerik code, setting item.Value = Node2.ID.ToString(); caused it to render in a hidden input field.

I am responding to clicks anywhere in the tree, therefore I cannot use my existing code, which relied on a set relationship (it would work for first nodes (Node 1) not for anything nested below)

What I want is, whenever there is something like this, representing a node, which is then clicked:

<li class="t-item t-last">
                            <div class="t-bot">
                                <span class="t-in">Node 1.1.2</span>
                                <input class="t-input" name="itemValue" type="hidden" value="1453" />
                            </div>
                        </li>

I want the ID value out of the input, in this case 1453.

Hope this now makes a lot more sense.

if possible would love to extend this to also store in a variable how nested the element that is clicked is, i.e. if Node 1.1.2 is clicked return 2, Node 1.1 return 1 and node 1 returns 0

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T12:01:57+00:00Added an answer on May 20, 2026 at 12:01 pm

    It’s a little unclear what you’re asking, but based on your snippet of JavaScript, I’m guessing that you’re handling clicks to the lis of the tree & want to find the value of the nested hidden field? If so, you want something like this:

    function TreeView_onSelect(e) {
        var id = $(e.item).find(".t-input:first").val();
    }
    

    Edit: In answer to your follow-up question, you should be able to get the tree depth with the following:

    var depth = $(e.item).parents(".t-item").length;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using ASP.NET MVC there are situations (such as form submission) that may require a
I having an issue with the ASP.NET Treeview control. I create the treeview just
Will using MVC enabled Telerik controls with ASP.NET MVC violate the MVC model? And
I am using Telerik tree view control: http://demos.telerik.com/aspnet-mvc/treeview http://demos.telerik.com/aspnet-mvc/treeview/clientsideevents What I want to do
Currently using System.Web.UI.WebControls.FileUpload wrapped in our own control. We have licenses for Telerik. I
Using online interfaces to a version control system is a nice way to have
I am using Teleriks RadInputManager control to check that a password is between 7
using Telerik RadGrid* in a LINQ context, with ASP.NET/C#, how to truncate text to
I have a grid that is currently using Telerik Grids, I would like to
I am currently working on a document management system in ASP.NET 3.5 using the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.