EasyUI combotree 使用技巧

转载出处 :http://www.cnblogs.com/wangjunwei/p/4932366.html

复制代码
$('#areaName').combotree({
            url: '../Ajax/Common.ashx?Method=GetCombotreeData',
            multiple: true,
            checkbox: true,
            isShowPic: false,
            onCheck: function (node, checked) {
                //   MainJs.RemoveNodeAll('areaName');
            },
            onLoadSuccess: function (node, data) {
                var rootNode = data[0];//第一个节点
                if (rootNode) {
                    var t = $('#areaName').combotree('tree'); // 获取树对象
                    var node1=t.tree('find', rootNode.id);
                    t.tree("uncheck", node1.target); //取消所有的选中
                }
            }
        });
复制代码

默认选中根节点的方法

复制代码
 onLoadSuccess: function (node, data) {
                var t = $('#WAY_JY').combotree('tree'); // 获取树对象
                var rootNode = t.tree('getRoot');//基础节点
                //var node1 = t.tree('find', rootNode.id);
                t.tree("uncheck", rootNode.target); //取消所有的选中
            }
复制代码

 json格式

复制代码
[
  {
    "id": 1,
    "text": "My Documents",
    "children": [
      {
        "id": 11,
        "text": "Photos",
        "state": "closed",
        "children": [
          {
            "id": 111,
            "text": "Friend"
          },
          {
            "id": 112,
            "text": "Wife"
          },
          {
            "id": 113,
            "text": "Company"
          }
        ]
      },
      {
        "id": 12,
        "text": "Program Files",
        "children": [
          {
            "id": 121,
            "text": "Intel"
          },
          {
            "id": 122,
            "text": "Java",
            "attributes": {
              "p1": "Custom Attribute1",
              "p2": "Custom Attribute2"
            }
          },
          {
            "id": 123,
            "text": "Microsoft Office"
          },
          {
            "id": 124,
            "text": "Games",
            "checked": true
          }
        ]
      },
      {
        "id": 13,
        "text": "index.html"
      },
      {
        "id": 14,
        "text": "about.html"
      },
      {
        "id": 15,
        "text": "welcome.html"
      }
    ]
  }
]
复制代码

 清空控件的值:

$("#type").combotree('clear');//清空控件的值

---->

posted @ 2017-08-10 14:54  像艳遇一样忧伤c  阅读(309)  评论(0编辑  收藏  举报