Find node by id

Thread is closed for posting
6 posts, 1 answers
  1. OfficeHeart
    OfficeHeart avatar
    99 posts
    Member since:
    Aug 2008

    Posted 27 Aug 2012 Link to this post


    Is it possible to find a node by id (clientside)?

    Here is how we populate the treeview.

    public JsonResult _AjaxLoading(string id)
    IEnumerable nodes = from item in GetDirectorys()
    where (id == null ? item.parent == "" : item.parent == id)
    select new
    id =,
    Name =,
    hasChildren = item.aantal > 0,
    return Json(nodes, JsonRequestBehavior.AllowGet);
  2. Answer
    Alex Gyoshev
    Alex Gyoshev avatar
    2515 posts

    Posted 27 Aug 2012 Link to this post

    Hello Martin,

    You can use the HierarchicalDataSource get method if you use a build newer than 2012.2.725. It will return the dataItem that contains the given id. After that, you can get the node reference through the treeview getByUid, supplying the dataItem uid:

        var dataSource = treeview.dataSource;
        var dataItem = dataSource.get(5); // find item with id = 5
        var node = treeview.findByUid(dataItem.uid);

    Alex Gyoshev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Horacio
    Horacio avatar
    1 posts
    Member since:
    Nov 2012

    Posted 21 Nov 2012 Link to this post

    Hello Alex

    I'm new with Kendo. I'm trying to do something like you said but it doesn't work for me. I think that I have the build 2012.2.710 but I have not yet paid the license because I'm testing Kendo to develop my app. Should I get the commercial license to get the build you said?

    Thanks in advance,

  4. Chris H.
    Chris H. avatar
    1 posts
    Member since:
    Mar 2010

    Posted 04 Dec 2012 Link to this post

    I've tried to use the 'get' method of HierarchicalDataSource on version v2012.3.1114 without success.

    It seems that the child-items haven't been properly loaded with it's properties

    The only way I've made this work, is by calling
    treeview.expand(".k-item"); (expand the whole tree) BEFORE calling  dataSource.get(); on a child-item

    I finally managed to get it working.
    The trick was to set 'loadOnDemand' property to 'false':
    Seriously: These kinds of things really need to be clearly documentet . It's not the first time I've spent a couple of days trying to figure out why kendoUI isn't behaving as expected, then just to find out it was a matter of configuration
    var faqMenu=$("#menutree");
        dataSource: dsFaqCategories,
  5. Andrii
    Andrii avatar
    13 posts
    Member since:
    Nov 2011

    Posted 30 May 2013 Link to this post

    Hi! Method of Alex Gyoshev helps only when i looking for root items, but nested elements i can't find by dataSource.get(id).
    Does anybody knows how to get nested node by id? Thanks!

    Sorry, it works)) It was my fault.
  6. Shruthika
    Shruthika avatar
    6 posts
    Member since:
    May 2013

    Posted 12 Jun 2013 Link to this post

    Hi have the same issue. can anyone help me resolve the issue?
    var inlineDefault = new{
                    transport: {
                        read: {
                            cache: false,
                            url: "/menu/GetTree",
                            dataType: "json",
                            data: { 'id':  $('#menuId').val(), 'netId': $('#networkId').val() }
                    schema: {
                        model: {
                            id: "id",
                            children: "Items",
                            hasChildren: "hasChildren"
                    template: '# if(item.isOvr) { # <b>#=item.txt#</b># } else { ##=item.txt## }#',
                    select: function (e) {
                        //new node selected clear previous messages
                        if (this.dataItem(e.node) != null) {
                    dataSource: inlineDefault
    and I select a specific node using
    function setTreeSelectedNode(nodeId) {
                var dataItem = $("#treeview").data("kendoTreeView").dataSource.get(nodeId);
                var node = $("#treeview").data("kendoTreeView").findByUid(dataItem.uid); // Error : dataitem is null if I pass the child Id
Back to Top