How to populate indetermined states when loading on demand ajax/json

2 posts, 0 answers
  1. Ali
    Ali avatar
    1 posts
    Member since:
    Nov 2015

    Posted 28 Dec 2016 Link to this post

    Hello, 

    I am loading a large list with checkboxes, some of the nodes have several subnodes checked and the data is peristed in a database.

    I am using on demand loading with ajax json calls.

    I can set the checkbox to true or false, but is there a way to set it to indetermined?

  2. Veselin Tsvetanov
    Admin
    Veselin Tsvetanov avatar
    354 posts

    Posted 30 Dec 2016 Link to this post

    Hello Ali,

    I would suggest you to try the CheckboxTemplate approach, proposed in the following blog post. Note that the suggested implementation is for MVC HTML helper. It would be translated to the following JavaScript initialization:
    $("#treeview").kendoTreeView({
        checkboxes: {
            checkChildren: true,
            template: "<input type='checkbox' name='checkedNodes' value='#= item.id #' #if(item.checked) { # checked # } if(item.indeterminate) { # data-indeterminate # } #/>"
        },
        dataSource: {
            transport: {
                read: {
                    url: serviceRoot + "/Employees",
                    dataType: "jsonp"
                }
            },
            schema: {
                model: {
                    id: "EmployeeId",
                    hasChildren: "HasEmployees"
                }
            }
        },
        dataTextField: "Name",
        dataBound: updateTree
    });

    Regards,
    Veselin Tsvetanov
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top