Test demo 2 of jquery and zTree tree structure, jqueryztree

Source: Internet
Author: User

Test demo 2 of jquery and zTree tree structure, jqueryztree

Js Code: $ (function () {initTree ("dxTxl", CONST_URL.LOAD_DXTREE, "id", "yhzid"); // initialize the initTree ("yjTxl", CONST_URL.LOAD_YJTREE, "id", "yhzid"); // initialize the email address book} // construct zTreefunction initTree (zTreeID, url, id, pid) {var setting = {check: {enable: true // display checkbox}, data: {key: {name: "xm"}, simpleData: {enable: true, idKey: "id", pIdKey: "yhzid" }}, callback: {onCheck: getCheckedData // method triggered when the checkbox value is changed}; $. 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) {// check if (treeNode. isParent) {// determine whether it is a parent node var childrenNodes = treeNode. children; // obtain the child Node object if (childrenNodes) {$. each (childrenNodes, function () {setDxOrYj (this); // set the value to the input box}) ;}} else {setDxOrYj (TreeNode) ;}} else {// uncheck the operation if (treeNode. isParent) {var childrenNodes = treeNode. children; if (childrenNodes) {$. each (childrenNodes, function () {clearDxOrYj (this); // clear the value of the input box}) ;}} else {clearDxOrYj (treeNode );}}} // input the set value function setDxOrYj (treeNode) {if (treeNode. txllx = "001") {// Text Message Address Book if ($ ('# dxsxr '). val () = "") {$ ('# dxsxr '). val (treeNode. sj);} else {$ ('# dxsxr '). val ($ ('# dxsxr '). val () + ";" + treeNode. sj );}} Else if (treeNode. txllx = "002") {// email address book if ($ ('# yjsjr '). val () = "") {$ ('# yjsjr '). val (treeNode. dzyj);} else {$ ('# yjsjr '). val ($ ('# yjsjr '). val () + ";" + treeNode. dzyj) ;}}// clear the receiver input box value function clearDxOrYj (treeNode) {var data = ""; if (treeNode. txllx = "001") {// Text Message 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") {// Email 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 );}}

Related Article

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.