EXTJS4 treepanel Multiple checkboxes First select multiple nodes in the multi-node expansion

Source: Internet
Author: User

<%@ page contenttype= "text/html; Charset=utf-8 "%>var checkednodes = {_data:{},update:function (id,text,checked) {if (checked) {This.add (Id,text, checked);} else if (!checked) {This.delbyid (ID);}},clear:function () {for (var key in this._data) {delete This._data[key];}    This._data = {};}, Add:function (Id,text) {if (!this._data[id]) {This._data[id] = {' id ': ID, ' text ': text};} },delbyid:function (ID) {if (This._data[id]) {delete this._data[id];}},getbyid:function (ID) {return this._data[id];}, Joinid:function (Sep) {arr = [];for (ID in this._data) {Arr.push (id);} return Arr.join (Sep);},joinname:function (Sep) {arr = [];for (ID in this._data) {Arr.push (this._data[id].text);} return Arr.join (Sep)},getcheckedorgids:function () {arr = [];for (ID in this._data) {Arr.push (id);} return Arr;},contains:function (ID) {return this_data[id];},init:function (ids,texts) {if (ids = = ") {return;} if (Ids.indexof (', ') > 0) {idarr = Ids.split (', '); if (texts) {Textarr = Texts.split (', '); for (var i=0; i< Idarr.length; i++) {if (Idarr[i].replace (/^\s+|\s+$/g, ')! = ') {This.add (idarr[i],textarr[i]);}}} Else{for (var i=0; i<idarr.length; i++) {this.add (idarr[i],null);}} }}};var ischeckevent = False;var isChecked = false; Ext.define (' OrgInfo ', {extend: ' Ext.data.Model ', fields: [{name: ' ID '}, {name: ' Orgtype                  '}, {name: ' InternalAddress '}, {name: ' Orgcode '}, {name: ' Dateto '},                  {name: ' Orgleadernum '}, {name: ' Orgidparent '}, {name: ' Code '},                  {name: ' OrgName '}, {name: ' text ', Mapping: ' OrgName '}, {name: ' Datefrom '}, {name: ' Orglevel '}, {name: ' Leaf '}]}); var orgstore = ext.create (' Ext.data.TreeStore ', { Defaultrootid: "A", Model: "OrgInfo", Root: {id:82,text: ' Shun Fung Express Group ', Leaf:false},proxy: {type: ' Ajax ', Actionmethods: " POST ", url: ' loadroleorg.action ', Reader:{type: ' JSON '}},nodeparam: ' id ', TextfielD: "Name", Autoload:false});/** set child node or parent node selected method * Set single node selected method */var Treenodecheck ={setnodechecked:function (node, Checked) {checkednodes.update (' node.get (' id '), node.get (' text '), checked), Node.set (' checked ', checked);}, Childchecked:function (node,checked) {treenodecheck.setnodechecked (node,checked); Node.expand (False,function () {if (Node.haschildnodes ()) {Node.eachchild (function (child) {treenodecheck.childchecked (child,checked);});}},this);},parentchecked:function (node,checked)   {var parentnode = Node.parentnode;   Checked = ParentNode = = null?null:checked; Treenodecheck.setnodechecked (node,checked);   Set parent node Unchecked if (ParentNode!=null) {//If parent node is not empty then expand var flag = false;   Parentnode.eachchild (function (child) {if (child.data.checked = = true) {flag = true;              }              });                   if (checked = = False) {if (!flag) {treenodecheck.parentchecked (parentnode,checked);              }}else{if (flag) {treenodecheck.parentchecked (parentnode,checked);           }   }         }   }}; Ext.define ("Orgtreepanel", {extend: "Ext.tree.Panel", Store:orgstore, Rootvisible:true, u Searrows:true, Frame:true, autoscroll:true, padding: ' Ten ten ', selectids:function             () {var records =this.getview (). getchecked (), ids = [];             Ext.Array.each (Records, function (rec) {Ids.push (Rec.get (' id '));             });        Return Ids.join (","); }, listeners:{/**itemexpand:function (NODE,EOPTS,AA) {console.info ('-------------------BEFOREITEMEXPA        nd ');        Ischeckevent = false;        if (ischeckevent) {ischeckevent = null}else if (ischeckevent = = null) {ischeckevent = false;           }},**/checkchange:function (node,checked,eopts) {ischeckevent = true;           isChecked = checked;                         Treenodecheck.childchecked (node,checked); TreenodechecK.parentchecked (node,checked);        }, Load:function (store, records, successful, operation, eopts) {/*if (records.data.checked!=null) {                Console.log ("-----------------" +records.data.checked+ ", Ischeckevent:" +ischeckevent+ ", isChecked:" +ischecked "); if (ischeckevent | | ischeckevent = = NULL) {} Ext.Array.each (successful, function (REC) {T                   Reenodecheck.childchecked (REC, isChecked);        });              }*//*if (records.data.checked!=null) {var haschecked = false;              Ext.Array.each (successful, function (REC) {if (rec.data.checked) {haschecked = true;              return false;              }                   });                 if (!records.data.checked) {if (haschecked) {Ext.Array.each (successful, function (REC) {                     Treenodecheck.childchecked (Rec,false);              }); }}else{if (!haschecked) {Ext.Array.each (successful, function (REC) {TREENODECHECK.CHILDC                     Hecked (rec,true);              });     }              }          }*/        }        }    });

  

EXTJS4 treepanel Multiple checkboxes First select multiple nodes in the multi-node expansion

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.