Checking certain nodes on Load of treeview

4 posts, 1 answers
  1. Answer
    Keith avatar
    33 posts
    Member since:
    Jan 2013

    Posted 01 May 2013 Link to this post


    I have a tree view with a list of nodes which have checkboxes. Once a user checks some of the nodes I persist this information to the database.  I then want to load this info back onto the page.  I cannot seem to get this working.

    I'm doing something like:

                    checkboxes: {                    
                        template: "<input type='checkbox' #= CheckItem(item.IsSet) # />"
                    dataSource: inline,
                    dataTextField: ["ComponentActionName"],
                    loadOnDemand: false

    function CheckItem(IsSet) {
                if (IsSet) {
                    return "checked='checked'";
                else {
                    return "";

    This actually works fine, in that the UI shows the correct nodes checked.  The problem is that when I try to save this data again with a function like:

    function checkedNodeIds(nodes, checkedNodes) {
                for (var i = 0; i < nodes.length; i++) {
                    if (nodes[i].checked) {

                    if (nodes[i].hasChildren) {
                        checkedNodeIds(nodes[i].children.view(), checkedNodes);

    nodes[i].checked shows as undefined for the nodes unless I manually unselect and reselect them.  Is there a property similar to the dataTextField where I can specify the field on the data which indicates if the node should be checked or any other way of achieving this?

  2. Alex Gyoshev
    Alex Gyoshev avatar
    2527 posts

    Posted 02 May 2013 Link to this post

    Hello Keith,

    The data*Field configuration options are not available for item states (checked/enabled/selected). The most robust way to achieve this goal is to transform the data through the schema.parse method, like shown in this jsBin.

    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. marco
    marco avatar
    36 posts
    Member since:
    Sep 2007

    Posted 05 Oct 2016 in reply to Alex Gyoshev Link to this post

    Dear Alex,

    The link you provided as a solution is not available anymore.

    Could you please tell me how to make some nodes checked by default on loading depending their status in the Database (or in a JSON file)?

  4. Alex Gyoshev
    Alex Gyoshev avatar
    2527 posts

    Posted 05 Oct 2016 Link to this post

    Hello Marco,

    It appears to have been a temporary problem with the jsBin service. The link is functional now -- the important bit is the definition of the schema.parse function, which maps the properties:

            parse: function(response) {
              for (var i = 0; i < response.length; i++) {
                response[i].checked = response[i].IsSet;
              return response;


    Alex Gyoshev
    Telerik by Progress
    Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
Back to Top