Get count of Checked child node at Parent node in TreeView

2 posts, 0 answers
  1. Prashant
    Prashant avatar
    4 posts
    Member since:
    Jul 2015

    Posted 27 Aug 2015 Link to this post

    i am using treelist and treeview both.
    and i am having checkbox inside it.
    i am fetching checked items database.
    i have binded it correctly but not able to display count of checked node at parentnode.
    i want to display the count of checked item count at parent level in treelist

    parent1 (1)


    ------checked childchild(1)

    ------notchecked childchild

    like this

    Plz help me.

  2. Ivan Danchev
    Ivan Danchev avatar
    1951 posts

    Posted 31 Aug 2015 Link to this post


    If you are loading the TreeView nodes from a database you can subscribe to the TreeView's OnClientLoad client-side event and use the following code in its handler, in order to show the number of checked child items (x):
    function OnClientLoad(sender) {
        var allNodes = sender.get_allNodes()
        for (var i = 0; i < allNodes.length; i++) {
            var childNodes = allNodes[i].get_allNodes();
            var checkedCount = 0;
            for (var j = 0; j < childNodes.length; j++) {
                if (childNodes[j].get_checked()) {
            var newText = " (" + checkedCount + ")";
            allNodes[i].set_text(allNodes[i].get_text() + newText);

    Ivan Danchev
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top