2017-12-30 21 views
2

どのように私は親の選択子の数を制限することができますか? 私のチェックノード用jstreeで選択した親の子の数を制限する方法は?

function buildTree(data) { 
    var dataJson = JSON.parse(data); 
    $("#onflycheckboxes").jstree({ 
     "json_data": { 
      data: dataJson, 
     }, 
     checkbox: { 
      real_checkboxes: true, 
      checked_parent_open: true, 
      three_state: false 
     }, 
     "search": { 
      "case_insensitive": true, 
      "show_only_matches": true 
     }, 
     "plugins": ["themes", "json_data", "ui", "checkbox", "search"] 

    }); 
} 

答えて

5

を助けてください、あなたはjstreeに

function buildTree(data) { 
var dataJson = JSON.parse(data); 
$("#onflycheckboxes").jstree({ 
    "json_data": { 
     data: dataJson, 
    }, 
    checkbox: { 
     real_checkboxes: true, 
     checked_parent_open: true, 
     three_state: false 
    }, 
    "search": { 
     "case_insensitive": true, 
     "show_only_matches": true 
    }, 
    "plugins": ["themes", "json_data", "ui", "checkbox", "search"] 

}).bind("before.jstree", function (e, data) { 

     if (data.func === "check_node") { 
      if ($("#onflycheckboxes").jstree('get_checked').length >= numberOfCompanies) { 
       e.preventDefault(); 

       toastMessage();//your message for show to user can't select any more 
       return false; 
      } 
     } 
    });; 
+0

$("#onflycheckboxes").jstree('get_checked')を使用しなければならないくらいよ、あなたは私を救ったあなたに感謝し、 – arsenalover

+0

どういたしまして):) –

関連する問題