jquery and Ztree tree structure test Demo 2

Source: Internet
Author: User

JS Code: $ (function () {Inittree ("DXTXL", Const_url. Load_dxtree, "id", "Yhzid");//Initialize SMS Address Book Inittree ("Yjtxl", Const_url. Load_yjtree, "id", "Yhzid");//Initialize mail Address Book}//Build Ztreefunction Inittree (ztreeid,url,id,pid) {var setting = {che CK: {enable:true//Show checkbox}, Data: {key: {name: ' XM '}, Simpledata: {Enab    Le:true, IdKey: "id", PIdKey: "Yhzid"}}, callback: {Oncheck:getcheckeddata               CheckBox Value Change Trigger method}};$.ajax ({type: "Get", DataType: "JSON", Url:url,                Success:function (data) {$.fn.ztree.init ($ ("#" +ztreeid), setting, Data.data);        }   });} Trigger method function Getcheckeddata (E,treeid,treenode) {if (treenode.checked) {//Tick action if (treenode.isparent) {//Determine if parent section  Point var childrennodes = Treenode.children;                      Gets the child node of the object if (childrennodes) {$.each (Childrennodes,function () {                       Setdxoryj (this); To the input box set value}); }}else{setdxoryj (TreeNode);}} else{//Uncheck operation if (treenode.isparent) {var childrennodes = Treenode.children; if (childrennodes) {$.each (Childrennodes,                                         function () {cleardxoryj (this);//Empty the value of the input box }); }}else{cleardxoryj (TreeNode);}}} Go to the Recipient input box set value function Setdxoryj (treeNode) {if (treenode.txllx== "001") {///SMS Address Book if ($ (' #dxsxr '). val () = = "") {$ (' #dxsxr ') ). Val (TREENODE.SJ);} else{$ (' #dxsxr '). Val ($ (' #dxsxr '). Val () + ";" +TREENODE.SJ);}} else if (treenode.txllx== "002") {//mail Address Book if ($ (' #yjsjr '). val () = = "") {$ (' #yjsjr '). Val (Treenode.dzyj);} else{$ (' #yjsjr '). Val ($ (' #yjsjr '). Val () + ";" +treenode.dzyj);}}} Eliminate the value of the Recipient input box function Cleardxoryj (treeNode) {var data = "", if (treenode.txllx== "001") {//SMS Address Book var dxdata = ($ (' #dxsxr '). Val ()). Split (";"); for (Var i=0;i<dxdata.length;i++) {if (Treenode.sj!=dxdata[i]) {if (data== "") {data + = Dxdata[i];} Else{data+= ";" +dxdata[i];}};} $ (' #dxsxr '). val (data);} else if (treenode.txllx== "002") {//mail address Book var yjdata = $ (' #yjsjr '). Val (). Split (";"); for (Var i=0;i<yjdata.length;i++) {if (Treenode.dzyj!=yjdata[i]) {if (data== "") {data + = Yjdata[i];} Else{data + = ";" +yjdata[i];}};} $ (' #yjsjr '). val (data);}}

jquery and Ztree tree structure test Demo 2

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.