javascript - How to realize multi-layer nested linkage of tree component with checkbox
滿天的星座
滿天的星座 2017-06-26 10:50:15
0
1
656

I am currently making a tree component with a checkbox. My rendering idea is to recurse from the parent class to the child class. If there is a children attribute, let children call itself. The code is as follows

     data = [{
        label: 111,
        children: [{
            label: 222,
        }]
      },  {
        label: 333
      }]
    translate = (content, key, first) => {
        content.forEach((i, index) => {
            i.key = key + (first ? '' : '-') + (index + 1);
            i.checked = this.defaultCheckedKey.toString().indexOf(i.key) > -1;
            i.expanded = this.defaultExpandedKey.toString().indexOf(i.key) > -1;
            i.nodeLevel = i.key.split('-').length;
            i.checked && selectedKeys.push(i.key);   
            if (i.children && i.children.length > 0) {
                this.translate(i.children, i.key, false);
            }
        })
    };
    ngOnInit() {      
       this.translate(this.data, '', true);
    }

Now we need to do checkbox selection linkage. If we recurse from the parent class to the child class, n-1 recursions are needed, which seems to affect the performance. Can anyone give me a solution for checkbox multi-layer nested linkage?

滿天的星座
滿天的星座

reply all(1)
巴扎黑

http://www.treejs.cn/v3/main....

Let’s see if this plug-in can satisfy

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template