Get Node Level on DataBound

2 posts, 0 answers
    UBALDI SI avatar
    9 posts
    Member since:
    Jul 2013

    Posted 06 Nov 2017 Link to this post


    I want to hide the CreateChild command ont he third level of my nodes.
    So if wonder if a way to get the node level of an element exists on databound event ?

    Or maybe ther is a better way to accomplish it ?

    I started the databound event like this:

    function dataBound(treeview) {
        var node;
        var nodes = treeview.sender.dataSource.view();
        for (var i = 0; i < nodes.length; i++) {
            node = nodes[i];

    I don't want use the hasChildren attribut beacause in my model sometimes element at level 2 doesn't have children.    

    Thank you in advance

  2. Stefan
    Stefan avatar
    2472 posts

    Posted 08 Nov 2017 Link to this post

    Hello, Jeremy,

    The desired result can be achieved by checking if the item has a parentId and then checking if that parentId has a parentId as well. This will hide the buttons for all levels under the 3rd. If it has to be only for the third the logic should add a check to hide the button if the last item does not have a parentId(it is the first level node):

    I made an example demonstrating this:

    I hope this will help to achieve the desired result.

    Progress Telerik
    Try our brand new, jQuery-free Angular 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