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
- $ ("Xxxid"). Combotree ({
- Data: [{... ...},{......},{...}],//omitted
- Required: false,
- Onbeforeselect: function (node) {
- If (!$ (this). Tree ("isleaf", Node.target)) {//If it is not a leaf node, do not let the selection
- return false;
- }
- }
- });
Second, the way two: control can only select one item, after selecting an item can not be checked again (experience more blunt)
JS Code
- $ ("Xxxid"). Combotree ({
- Multiple: true,//settings can be multi-selected, display multi-box, do not set the multi-box will not appear
- Data: [{... ...},{......},{...}],//omitted
- Required: false,
- CheckBox: True,//Show multi-marquee
- Onlyleafcheck: True,//Show multiple boxes only on leaf nodes
- Onbeforeselect: function (node) {
- If (!$ (this). Tree ("isleaf", Node.target)) {//If it is not a leaf node, do not let the selection
- return false;
- }
- },
- Onbeforecheck: Function (node, checked) {//control can only select one item
- if (checked) {//is currently selected
- var nodes = $ (this). Tree ("getchecked");
- //control can only select one item, after selecting an item can not be checked again
- if (nodes.length = = 0) {
- return true;
- }else{
- return false;
- }
- }else{//is currently unchecked
- return true;
- }
- }
- });
Three, way three: arbitrarily choose any one, but only one option (perfect version)
JS Code
- $ ("Xxxid"). Combotree ({
- Multiple: true,//settings can be multi-selected, display multi-box, do not set the multi-box will not appear
- Data: [{... ...},{......},{...}],//omitted
- Required: false,
- CheckBox: True,//Show multi-marquee
- Onlyleafcheck: True,//Show multiple boxes only on leaf nodes
- Onbeforeselect: function (node) {
- $ (this). Tree ("Check", node.target); Control the click of text can also be checked
- return false; Avoid selecting a tick box instead of clicking on the text to appear with a yellow selected stripe
- },
- Onbeforecheck: Function (node, checked) {//control can only select one item
- if (checked) {//is currently selected
- var nodes = $ (this). Tree ("getchecked");
- //control can only select one item, after selecting an item can not be checked again
- if (nodes.length > 0) {
- For (var i=0; i<nodes.length; i++) {
- $ (this). Tree ("uncheck", nodes[i].target); Clear the previously selected item
- }
- }
- }
- }
- });
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