treeview append always "undefined"

3 posts, 0 answers
  1. Wyatt
    Wyatt avatar
    22 posts
    Member since:
    Aug 2012

    Posted 21 Feb 2014 Link to this post

    Below you can see the pertinent code.  when I try to append a new node in the tree it's always "undefined" when I check $("#appendNodeText").val() it does have the correct value.  What am I missing?

                                    .HtmlAttributes(new { @class = "col-md-6", id = "treeview" })

                        .DataSource(dataSource => dataSource
                            .Read(read => read
                                .Action("Categories", "DisplayArticle")
                        .Events(events => events

            <input id="appendNodeText" value="Node" class="k-textbox" />
            <button class="k-button" id="appendNodeToSelected">Append node</button>

        var treeview = $("#treeview").data("kendoTreeView"),
            handleTextBox = function (callback) {
                return function (e) {
                    if (e.type != "keypress" || kendo.keys.ENTER == e.keyCode) {

            var append = handleTextBox(function (e) {
                //var treeview = $("#treeview").data("kendoTreeView")
                var selectedNode =;

                // passing a falsy value as the second append() parameter
                // will append the new node to the root group
                if (selectedNode.length == 0) {
                    selectedNode = null;
                    Name: $("#appendNodeText").val(),
                    id: $("#appendNodeText").val(),
                    text: $("#appendNodeText").val()
                }, selectedNode);

  2. Alex Gyoshev
    Alex Gyoshev avatar
    2497 posts

    Posted 25 Feb 2014 Link to this post

    Hello Wyatt,

    The TreeView is configured to use the Title field (through the DataTextField("Title") invocation). Thus, when appending items, you should specify that field instead of the default one (text). 

           Title: $("#appendNodeText").val()
        }, selectedNode);

    Alex Gyoshev
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. ali
    ali avatar
    13 posts
    Member since:
    Dec 2010

    Posted 31 May 2015 Link to this post

    i used name property instead of text or title
    and worked

                Name: nodeText,

                id: nodeValue

            }, selectedNode);
Back to Top