Jquery Easyui combotree can only select leaf nodes and leaf nodes have multi-marquee

Source: Internet
Author: User

Jquery Easyui combotree can only select leaf nodes and leaf nodes have multi-marquee

jquery Easyui combotree Single box, jquery Easyui combotree can only select leaf nodes

Easyui combotree leaf node added single box

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

? Copyright Sweet Potato Yiu April 28, 2018

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

Recommended Use method three (perfect version)

One, mode one, the simplest (can only be single-leaf node, leaf node Front no multi-box)

JS Code
  1. $ ("Xxxid"). Combotree ({
  2. Data: [{... ...},{......},{...}],//omitted
  3. Required: false,
  4. Onbeforeselect: function (node) {
  5. If (!$ (this). Tree ("isleaf", Node.target)) {//If it is not a leaf node, do not let the selection
  6. return false;
  7. }
  8. }
  9. });

Second, the way two: control can only select one item, after selecting an item can not be checked again (experience more blunt)

JS Code
  1. $ ("Xxxid"). Combotree ({
  2. Multiple: true,//settings can be multi-selected, display multi-box, do not set the multi-box will not appear
  3. Data: [{... ...},{......},{...}],//omitted
  4. Required: false,
  5. CheckBox: True,//Show multi-marquee
  6. Onlyleafcheck: True,//Show multiple boxes only on leaf nodes
  7. Onbeforeselect: function (node) {
  8. If (!$ (this). Tree ("isleaf", Node.target)) {//If it is not a leaf node, do not let the selection
  9. return false;
  10. }
  11. },
  12. Onbeforecheck: Function (node, checked) {//control can only select one item
  13. if (checked) {//is currently selected
  14. var nodes = $ (this). Tree ("getchecked");
  15. //control can only select one item, after selecting an item can not be checked again
  16. if (nodes.length = = 0) {
  17. return true;
  18. }else{
  19. return false;
  20. }
  21. }else{//is currently unchecked
  22. return true;
  23. }
  24. }
  25. });

Three, way three: arbitrarily choose any one, but only one option (perfect version)

JS Code
  1. $ ("Xxxid"). Combotree ({
  2. Multiple: true,//settings can be multi-selected, display multi-box, do not set the multi-box will not appear
  3. Data: [{... ...},{......},{...}],//omitted
  4. Required: false,
  5. CheckBox: True,//Show multi-marquee
  6. Onlyleafcheck: True,//Show multiple boxes only on leaf nodes
  7. Onbeforeselect: function (node) {
  8. $ (this). Tree ("Check", node.target); Control the click of text can also be checked
  9. return false; Avoid selecting a tick box instead of clicking on the text to appear with a yellow selected stripe
  10. },
  11. Onbeforecheck: Function (node, checked) {//control can only select one item
  12. if (checked) {//is currently selected
  13. var nodes = $ (this). Tree ("getchecked");
  14. //control can only select one item, after selecting an item can not be checked again
  15. if (nodes.length > 0) {
  16. For (var i=0; i<nodes.length; i++) {
  17. $ (this). Tree ("uncheck", nodes[i].target); Clear the previously selected item
  18. }
  19. }
  20. }
  21. }
  22. });

Method Three: Onbeforeselect method return False, avoid the first click on the text is selected, then reopen the selection, do not click the text, directly tick the multi-box, the first click of the text has a yellow background, as follows:





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

? Copyright Sweet Potato Yiu April 28, 2018

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

Jquery Easyui combotree can only select leaf nodes and leaf nodes have multi-marquee

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.