Search code examples
javascriptjquerytreeviewbootstrap-treeview

How to disable parent node checkbox of Bootstrap Treeview


My treeveiw example

I want to keep my parent folder names uncheckable. but i can not pass the option with individual node here.

I wrote code like this.

$("#treeview-checkable").treeview({
        data: root.attributeTopicList,
        showIcon: true,
        showCheckbox: true,
        showBorder: false,
        showTags: true,
    });

};

Solution

  • I had to Add some lines in bootstrapp-treeview.js file

    Code looks like this

    Process-->>

    • Go inside bootstrapp_treeview.js

    • See how its render function works

    • You will find that after treeview fire any event or make any changes on DOM it calls its render method
    • You will find render method in line number 486
    • If you write your code in such way that your parent node should not have checkbox just write

          for (var i = 0; i < $(".glyphicon-minus").length; i++)
          {
              $($(".glyphicon-minus")[i]).siblings(".check-icon").hide();
          }
          for (i = 0; i < $(".glyphicon-plus").length; i++){
              $($(".glyphicon-plus")[i]).siblings(".check-icon").hide();
          }