3

I am using bootstrap treeview. For some reason, even the leaf nodes are having expand/collapse icons. I want to show expand/collapse icons only for non-leaf nodes?

I am using following config:

  $('#tree').treeview({data: scope.tree, showCheckbox: true});
  $('#tree').treeview('collapseAll', { silent: true });

I am sure there must be a configuration to enable disable expand/collapse icons for leaf nodes in treeview.

James A Mohler
  • 11,060
  • 15
  • 46
  • 72
SharpCoder
  • 18,279
  • 43
  • 153
  • 249

1 Answers1

5

To answer my own question, In the JSON, the nodes property needs to be set as null for leaf nodes. I was sending it as empty array []

var tree = [
  {
    text: "Parent 1",
    nodes: [
      {
        text: "Child 1",
        nodes: [
          {
            text: "Grandchild 1"
          },
          {
            text: "Grandchild 2"
          }
        ]
      },
      {
        text: "Child 2"
      }
    ]
  },

  {
    text: "Parent 4"
    nodes: []  // =======> set this as null
  }
];
SharpCoder
  • 18,279
  • 43
  • 153
  • 249