ext 4 check tree 聯動選擇

lzq0107發表於2020-04-07

轉自:http://yaoba.iteye.com/blog/1006445

 

 


 var tree = Ext.create('Ext.tree.Panel', {
  .....
  viewConfig : {
   onCheckboxChange : function(e, t) {
    var item = e.getTarget(this.getItemSelector(), this
        .getTargetEl()), record;
    if (item) {
     record = this.getRecord(item);
     var check = !record.get('checked');
     record.set('checked', check);

     if (check) {
      record.bubble(function(parentNode) {
         parentNode.set('checked', true);
        });
      record.cascadeBy(function(node) {
         node.set('checked', true);
        });
     } else {
      record.cascadeBy(function(node) {
         node.set('checked', false);
        });
     }
    }
   }
  }
 });
});

     

相關文章