随笔 - 240  文章 - 0  评论 - 8  阅读 - 13万

easyui combotree combobox 使用例子

复制代码
<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: '请选择下拉...',
                onHidePanel: function () {
                    var _options = $(this).combobox('options');
                    var _data = $(this).combobox('getData');/* 下拉框所有选项 */
                    var _value = $(this).combobox('getValue');/* 用户输入的值 */
                    var _b = false;/* 标识是否在下拉列表中找到了用户输入的字符 */
                    for (var i = 0; i < _data.length; i++) {
                        if (_data[i][_options.valueField] == _value) {
                            _b = true;
                            break;
                        }
                    }
                    if (!_b) {
                        $(this).combobox('setValue', '');
                    }
                }
            });
            $('#dd').combobox({
                method: 'get', //必须指明
                url: 'Data/combox1.json',//必须指明
                valueField: 'id',
                textField: 'text',
                editable: true,   //编辑,支持模糊查询
                //multiple: true,   //为true,出来多选框,勾选多个
                required: true,
                onChange: function (newValue, oldValue) {
                    reload();//实现联动
                }
            });
        });
        function reload() {
            $('#dd').combobox({
                method: 'reload', //必须指明
                url: 'Data/combox1.json?param='+'这里是传的新值'+'&a='+Math.random()//必须指明
            });
        }
        function GetData() {
            var t = $('#cc').combotree('getData');
            alert(t.length);
        }
        function SetDefault() {
            var t = $('#cc').combotree('getData');
            $('#cc').combotree('select',t[0].id);
        }
        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>
复制代码

 

posted on   biind  阅读(5989)  评论(0编辑  收藏  举报
编辑推荐:
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示