easyui combotree combobox 使用例子

Posted biind

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了easyui combotree combobox 使用例子相关的知识,希望对你有一定的参考价值。

一:引入easyui

二:使用例子

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="Resurces/themes/easyui.css" rel="stylesheet" />
    <link href="Resurces/themes/icon.css" rel="stylesheet" />
    <script src="Resurces/javascript/jquery.min.js"></script>
    <script src="Resurces/Javascript/jquery.easyui.min.js"></script>
    <script>
        $(function () {
            $(#cc).combotree({
                method: get, //必须指明
                url: Data/tree_data1.json,//必须指明
                editable: true,   //编辑,支持模糊查询
                multiple: true,   //为true,出来多选框,勾选多个
                required: true,
                missingMessage: 不能为空,请选择,
                prompt: 请选择下拉...
            });
            $(#dd).combobox({
                method: get, //必须指明
                url: Data/combox1.json,//必须指明
                valueField:id,
                textField:text,
                editable: true,   //编辑,支持模糊查询
                multiple: true,   //为true,出来多选框,勾选多个
                required: true                
            });
        });
        function getValues() {
            var t = $(#cc).combotree(getValues);
            alert(t);
        }
        function getValue() {
            var t = $(#cc).combotree(getValue);
            alert(t);
        }
        function setValues() {
            $(#cc).combotree(setValues, [111, 112]);
        }
        function setValue() {
            $(#cc).combotree(setValue, 11);
        }
        function disable() {
            $(#cc).combotree(disable);
        }
        function enable() {
            $(#cc).combotree(enable);
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <input id="cc" />
            <input id="dd" />
            <input type="button" value="getValue" onclick="getValue()" />
            <input type="button" value="getValues" onclick="getValues()" />
            <input type="button" value="setValue" onclick="setValue()" />
            <input type="button" value="setValues" onclick="setValues()" />
            <input type="button" value="disable" onclick="disable()" />
            <input type="button" value="enable" onclick="enable()" />
        </div>
    </form>
</body>
</html>

 三:数据格式

1.tree_data1.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"
    }]
}]

2.combox1.json

[{
    "id":11,
    "text":"My Documents"     
    },{
        "id":12,
        "text":"Program Files"         
    }]

 

以上是关于easyui combotree combobox 使用例子的主要内容,如果未能解决你的问题,请参考以下文章

EasyUI——combotree

EasyuI comboxTree 使用笔记

easyui 下拉选择树(ComboTree) 的实现

easyui 下拉选择树(ComboTree) 的实现

easyui combobox 设置值

combotree(组合树)的使用