Jquery Easyui Combotree Expand all parent nodes according to the selected values

Source: Internet
Author: User

Jquery Easyui Combotree Expand all parent nodes according to the selected values

Jquery Easyui Combotree Expand the parent node,

Jquery Easyui Combotree expands all previous parent nodes according to the values selected by the child nodes.

Jquery Easyui Combotree Gets the selected value

================================

? Copyright Sweet Potato Yiu May 7, 2018

http://www.cnblogs.com/fanshuyao/

First, Combotree gets the parent node method GetParent, which is actually inherited from the tree plugin

JS Code
    1. Name Parameter Description
    2. GetParent Target Get The parent node,
    3. The target parameter indicate the node DOM object.

Tree gets the parent node:

JS Code
    1. $ ("#treeId"). Tree ("getParent", node.target);

Combotree Get parent node:

Java code
    1. var treeobj = $ ("#combotreeId"). Combotree ("tree"); Get the Combotree Tree object first
    2. var parentnode = Treeobj.tree ("GetParent", node.target);

Second, Combotree gets the selected value

Java code
    1. var treeobj = $ ("#combotreeId"). Combotree ("tree"); Get the Combotree Tree object first
    2. var nodeschecked = Treeobj.tree ("getchecked"); The tree object gets all the selected values of the tree, and there may be multiple

Third, expand parent node

JS Code
    1. $ ("#treeId"). Tree ("expand", Node.target); node is usually the parent

Iv. Expand all parent nodes based on the values selected by the leaf node

Expand methods for all parent nodes (recursively expand parent node):

JS Code
  1. /**
  2. * Expand all parent nodes according to leaf node
  3. * @param treeobj Tree object, (Combotree tree object gets: var treeobj = comboobj.combotree ("tree");)
  4. * @param node leaf nodes
  5. */
  6. function expandparent (treeobj, node) {
  7. var parentnode = Treeobj.tree ("GetParent", node.target);
  8. if (parentnode! = null && parentnode! = "undefined") {
  9. Treeobj.tree ("expand", Parentnode.target);
  10. Expandparent (Treeobj, parentnode);
  11. }
  12. };

The specific use is as follows:

JS Code
  1. $ ("#cmm_code_id"). Combotree ({
  2. Multiple: true,
  3. Required: true,
  4. CheckBox: True,
  5. Onlyleafcheck: True,//Only leaf nodes can be checked
  6. URL: "${pagecontext.request.contextpath}/xxx",
  7. Onbeforeselect: function (node) {
  8. $ (this). Tree ("Check", node.target); Control the click of text can also be checked
  9. return false;
  10. },
  11. Onbeforecheck: Function (node, checked) {
  12. if (checked) {//If it is a tick, clear the previously selected node (not checked)
  13. var nodes = $ (this). Tree ("getchecked");
  14. if (nodes.length > 0) {
  15. For (var i=0; i<nodes.length; i++) {
  16. $ (this). Tree ("uncheck", Nodes[i].target);
  17. }
  18. }
  19. }
  20. },
  21. Onloadsuccess: function (node, data) {
  22. var cmm_code_id_value = "${buildingnaming.cmm_code_id}";
  23. if (cmm_code_id_value! = null && $.trim (cmm_code_id_value)! = "") {
  24. var comboobj = $ ("#cmm_code_id");
  25. var treeobj = Comboobj.combotree ("tree");
  26. Comboobj.combotree ("SetValue", Cmm_code_id_value);
  27. var nodeschecked = Treeobj.tree ("getchecked");
  28. if (nodeschecked.length > 0) {
  29. For (var i=0; i<nodeschecked.length; i++) {
  30. Expandparent (Treeobj, nodeschecked[i]);
  31. }
  32. }
  33. }
  34. }
  35. });

================================

? Copyright Sweet Potato Yiu May 7, 2018

http://www.cnblogs.com/fanshuyao/

Jquery Easyui Combotree Expand all parent nodes according to the selected values

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.