Components/fab-treeview.js
// here is how you build your UL treeview recursively
here is how you build your UL treeview recursively
here is how you build your UL treeview recursively
addElements(items, parent, id, chkbox){
          if (items === undefined) {
            return;
          }
          var ul = document.createElement("ul");
          if (parent) {
              parent.appendChild(ul);
          }
          items.forEach((x) => {
            let li = document.createElement("li");
            let label = document.createElement('label');
            label.setAttribute('for','');
            if (chkbox == "true")
            {
                let n = document.createElement('input');
                n.setAttribute('type', 'checkbox');
                n.setAttribute('id', '');
                n.setAttribute('value', '');
                n.className = "";
                label.appendChild(n);
            }
            let span = document.createElement("span");
            span.innerHTML = x.name;
            label.appendChild(span);  
            li.appendChild(label);
            if (x.children && x.children.length > 0) {
                label.className = "caret";
                this.addElements(x.children, li, id, chkbox);
            }
            else {
                label.className = "indent";
            }
            if (ul.parentElement.id == id)
            {
                ul.id = "root";
            }
            else
            {
                ul.className = 'nested';
            }
            ul.append(li);
        });
      }
addElements ( items , parent , id , chkbox ) { if ( items === undefined ) { return ; } var ul = document . createElement ( "ul" ) ; if ( parent ) { parent . appendChild ( ul ) ; } items . forEach ( ( x ) => { let li = document . createElement ( "li" ) ; let label = document . createElement ( 'label' ) ; label . setAttribute ( 'for' , '' ) ; if ( chkbox == "true" ) { let n = document . createElement ( 'input' ) ; n . setAttribute ( 'type' , 'checkbox' ) ; n . setAttribute ( 'id' , '' ) ; n . setAttribute ( 'value' , '' ) ; n . className = "" ; label . appendChild ( n ) ; } let span = document . createElement ( "span" ) ; span . innerHTML = x . name ; label . appendChild ( span ) ; li . appendChild ( label ) ; if ( x . children && x . children . length > 0 ) { label . className = "caret" ; this . addElements ( x . children , li , id , chkbox ) ; } else { label . className = "indent" ; } if ( ul . parentElement . id == id ) { ul . id = "root" ; } else { ul . className = 'nested' ; } ul . append ( li ) ; } ) ; }
here is how you build your UL treeview recursively
here is how you build your UL treeview recursively
/* Add the node label */ /* Add a checkbox */ /* Add a span to the label */ // If the parent is th container, assign the id // else give it a nested class