欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

使用jQuery+EasyUI實(shí)現(xiàn)CheckBoxTree的級(jí)聯(lián)選中特效

 更新時(shí)間:2015年12月06日 11:11:06   投稿:hebedich  
這篇文章主要介紹了使用jQuery+EasyUI實(shí)現(xiàn)CheckBoxTree的級(jí)聯(lián)選中特效的相關(guān)資料,需要的朋友可以參考下

需求:子結(jié)點(diǎn)選中,父節(jié)點(diǎn)隨之選中,父節(jié)點(diǎn)取消,子節(jié)點(diǎn)隨之取消

代碼:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title></title>
  <link href="js/themes/default/easyui.css" rel="stylesheet" />
  <link href="js/themes/icon.css" rel="stylesheet" />
  <script src="js/jquery-1.8.0.min.js"></script>
  <script src="js/jquery.easyui.min.js"></script>
  <script src="js/locale/easyui-lang-zh_CN.js"></script>
  <script type="text/javascript">
    var data = [{
      "id": 1,
      "text": "系統(tǒng)",
      "children": [{
        "id": 11,
        "text": "用戶管理",
        "children": [{
          "id": 19,
          "text": "增加"
        }, {
          "id": 3,
          "text": "修改"
        }, {
          "id": 5,
          "text": "刪除"
        }]
      }, {
        "id": 12,
        "text": "角色管理",
        "children": [{
          "id": 13,
          "text": "增加"
        }, {
          "id": 3,
          "text": "修改"
        }, {
          "id": 5,
          "text": "刪除"
        }]
      }]
    }, {
      "id": 2,
      "text": "其他",
      "state": "closed"
    }];

    $(function () {
      $("#tt").tree({
        data: data,
        checkbox: true,
        cascadeCheck: false,
        onCheck: function (node, checked) {
          if (checked) {
            var parentNode = $("#tt").tree('getParent', node.target);
            if (parentNode != null) {
              $("#tt").tree('check', parentNode.target);
            }
          } else {
            var childNode = $("#tt").tree('getChildren', node.target);
            if (childNode.length > 0) {
              for (var i = 0; i < childNode.length; i++) {
                $("#tt").tree('uncheck', childNode[i].target);
              }
            }
          }
        }
      });
    });

    function getChecked()
    {
      var arr = [];
      var checkeds = $('#tt').tree('getChecked', 'checked');
      for (var i = 0; i < checkeds.length; i++) {
        arr.push(checkeds[i].id);
      }
      alert(arr.join(','));
    }

  </script>
</head>
<body>
  <ul id="tt"></ul>
  <input type="button" value="獲取選中" onclick="getChecked()" />
</body>
</html>

如圖:

相關(guān)文章

最新評(píng)論