• easyui enableFilter combobox级联 combotree


    //网格过滤
    function datagridFilter(dg) {
        dg.datagrid('enableFilter');
        dg.datagrid('enableFilter', [{
            field: 'townName',
            type: 'combobox',
            options: {
                url: 'area/getAreas.action?type=2&parentCode=330106',
                valueField: 'code',
                textField: 'name',
                onChange: function (value) {
                    //刷新数据,重新读取省份下的城市,并清空当前输入的值
                    var component = dg.datagrid('getFilterComponent', 'villageName');
                    component.combobox('reload', 'area/getAreas.action?type=2&parentCode=' + value);
                    if (value == '') {
                        dg.datagrid('removeFilterRule', 'townName');
                    } else {
                        dg.datagrid('addFilterRule', {
                            field: 'townName',
                            op: 'equal',
                            value: value
                        });
                    }
                    dg.datagrid('doFilter');
                },
                onLoadSuccess: function () {
                    var component = dg.datagrid('getFilterComponent', 'townName');
                    var component1 = dg.datagrid('getFilterComponent', 'villageName');
                    if (tvCode.length > 0) {
                        if (tvCode.length == 9) {
                            component.combobox('setValue', tvCode);
                            component1.combobox('reload', 'area/getAreas.action?type=2&parentCode=' + component.combobox('getValue'));
                        } else {
                            component.combobox('setValue', tvCode.substring(0, 9));
                            component1.combobox('reload', 'area/getAreas.action?type=2&parentCode=' + component.combobox('getValue'));
                            component.combobox('readonly', "true");
                        }
                    } else {
                        if (areaCode.length == 9) {
                            component.combobox('setValue', areaCode);
                            component.combobox('readonly', "true");
                            component1.combobox('reload', 'area/getAreas.action?type=2&parentCode=' + component.combobox('getValue'));
                        } else if (areaCode.length == 12) {
                            component.combobox('setValue', $("#areaCode").val().substring(0, 9));
                            component1.combobox('reload', 'area/getAreas.action?type=2&parentCode=' + component.combobox('getValue'));
                            component.combobox('readonly', "true");
                        } else {
                            dg.datagrid('doFilter');
                        }
                    }
                }
            }
        },
        {
            field: 'villageName',
            type: 'combobox',
            options: {
                //url:'area/getAreas.action?type=2&parentCode=330106',
                valueField: 'code',
                textField: 'name',
                onChange: function (value) {
                    //刷新数据,重新读取省份下的城市,并清空当前输入的值
                    if (value == '') {
                        dg.datagrid('removeFilterRule', 'villageName');
                    } else {
                        dg.datagrid('addFilterRule', {
                            field: 'villageName',
                            op: 'equal',
                            value: value
                        });
                    }
                    dg.datagrid('doFilter');
                },
                onLoadSuccess: function () {
                    var component = dg.datagrid('getFilterComponent', 'villageName');
                    var value = component.combobox('getValue');
                    if (tvCode.length == 12) {
                        component.combobox('setValue', tvCode);
                    }
                    if (areaCode.length < 12) {
                        dg.datagrid('addFilterRule', {
                            field: 'villageName',
                            op: 'equal',
                            value: value
                        });
                    } else if (areaCode.length > 9) {
                        component.combobox('setValue', areaCode);
                        component.combobox('readonly', "true");
                        dg.datagrid('addFilterRule', {
                            field: 'villageName',
                            op: 'equal',
                            value: value
                        });
                    }
                }
            }
        }]);
    }
    
    
    
    /**
    *使用combotree 示例
    */
    dg.datagrid('enbaleFilter',
        [{
            field: 'departmentName',
            type: 'combotree',
            options: {
                panelHeight: 'auto',
                multiple: true,
                url: 'commonaction/queryDepartmentorgTreeData.action',
                onLoadSuccess: function () {
                    var component = dg.datagrid('getFilterComponent', 'departmentName');
                    component.combotree('setValue', 4);
                },
                onChange: function (value) {
                    //var component = dg.datagrid('getFilterComponent', 'departmentName');
                    //var value=component.combotree('getValue');
                    dg.datagrid('addFilterRule', {
                        field: 'departmentName',
                        op: 'equal',
                        value: value
                    });
                    dg.datagrid("doFilter");
                }
            }
        }, {
            field: 'projectName',
            type: 'combotree',
            options: {
                url: "authorization/getProjectTreeByAccountId.action?accountId=" + $("#accountId").val(),
                panelHeight: "auto",
                editable: false, //不允许手动输入
                multiple: true,
                cascadeCheck: true,
                onLoadSuccess: function (data) { //数据加载完毕事件
                    var component = dg.datagrid('getFilterComponent', 'projectName');
                    var data = component.combotree('tree').tree("getRoots");
                    if (data.length > 0) {
                        component.combotree('tree').tree("check", data[0].target);//('select', data[0].target);
                    }
                },
                onChange: function (value) {
                    //var component = dg.datagrid('getFilterComponent', 'projectName');
                    //var data = component.combotree('tree').tree("getRoots");
                    //if (data.length > 0) {
                    //    component.combotree('tree').tree("check",data[0].target);//('select', data[0].target);
                    //}
                    var value = component.combotree('getValue');
                    dg.datagrid('addFilterRule', {
                        field: 'projectName',
                        op: 'equal',
                        value: value,
                    });
                    dg.datagrid("doFilter");
                }
            }
        }]);


    文章转自:http://www.cnblogs.com/ckaifeng/p/5006569.html

  • 相关阅读:
    从零到有模拟实现一个Set类
    node+express+mysql 实现登陆注册
    从路由原理出发,深入阅读理解react-router 4.0的源码
    linux rsyncserver文件同步
    为什么说Python是一门动态语言--Python的魅力
    python基础教程_学习笔记11:魔法方法、属性和迭代器
    list,set,map,数组间的相互转换
    TCP/IP协议族
    宿舍更换的新淋浴喷头"水温vs旋钮角度"关系的研究(曲线)
    单元測试中 Right-BICEP 和 CORRECT
  • 原文地址:https://www.cnblogs.com/apollokk/p/6713799.html
Copyright © 2020-2023  润新知