How to add node with ID

9 posts, 0 answers
  1. Thai
    Thai avatar
    9 posts
    Member since:
    Dec 2011

    Posted 20 Dec 2011 Link to this post


    I used method append to add new node to selected node:
           text: $("#text").val()

    But how can I append node with ID?
    somethings like:
           text: $("#text").val(),
           id: "some id"

  2. Richard
    Richard avatar
    3 posts
    Member since:
    Jan 2012

    Posted 26 Jan 2012 Link to this post

    I also would like to know the answer to this plus why does the append not display straight away?
  3. FieldTRAKS
    FieldTRAKS avatar
    25 posts
    Member since:
    Apr 2009

    Posted 29 Feb 2012 Link to this post

    this does not work for me either....i can't imagine a scenario where doing this kind of thing wouldn't be needed...can someone please answer this thread...seems like a big bug to me....basically you cannot add any attributes besides the node text using the append method
  4. Piotr Jarocki
    Piotr Jarocki avatar
    16 posts
    Member since:
    Feb 2010

    Posted 01 Mar 2012 Link to this post

    same thing here, i cant add custom attribute
  5. Alexander Valchev
    Alexander Valchev avatar
    2887 posts

    Posted 05 Mar 2012 Link to this post

    Hi guys,

    The idea has been already shared in our uservoice page, so if you wish you can give your votes for it here. The more votes it collects, the sooner it will be planned.

    Kind regards,
    Alexander Valchev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  6. Aron
    Aron avatar
    2 posts
    Member since:
    Feb 2012

    Posted 03 Apr 2012 Link to this post

    Until this option is added Ive managed to find a work around.   Its not brilliant but will add a node with an ID.

    Basically after you have initialised your treeview like so:

        dragAndDrop: true

    and you have appneded your node like so:

    var treeView = $("#treeView").data("kendoTreeView");
    treeView.append({ text: "Item 3" }, $("#n2"));

    use the find node by text funciton to find the node just added and apply an attribute ID and set it to whatever you wish.

    var foundNode = treeView.findByText("Item 3");
    foundNode.attr("id", "n5");

    The node should now have an id.  Im using to firebug to check this.  seems to work.

    See JS Fiddle for Ful Example >>

  7. Alex Gyoshev
    Alex Gyoshev avatar
    2515 posts

    Posted 03 Apr 2012 Link to this post

    See also this post, for another work-around for the problem.

    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!
  8. Alexandre Lepage
    Alexandre Lepage avatar
    9 posts
    Member since:
    Apr 2007

    Posted 09 Oct 2013 Link to this post

    Maybe library has changed, but now it's pretty simple.

    var treeView = $("#treeView").data("kendoTreeView");
    var node = treeView.append({ text: "Item 3" }, $("#n2"));
    node.attr("id", "n5");
  9. Steve C
    Steve C avatar
    1 posts
    Member since:
    Jul 2014

    Posted 06 Jan 2015 Link to this post

    For those people like me who come across this post years later the functionality Thai mentions is now supported in the Q3 2014 release (maybe before also)
    The following now works
    treeview.append({ text: "sometext", id: someid }, selectedNode);

    NOTE: If you have changed the text field using DataTextField or the 'id' name then you need to use your changed names rather than 'text' and 'id'.  If your unsure check the names in use with:     var dataItem = treeview.dataItem(selectedNode);
Back to Top