• 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

  • 相关阅读:
    大话设计模式--建造者模式 Builder -- C++实现实例
    HTTP状态码大全
    安装mongodb卡顿
    sublime_win配置
    sublime__最全面的 Sublime Text 使用指南
    sublime text 3搭建python 的ide
    spring boot与 spring.factories
    自定义xml spring bean
    统计分析: 跨库多表join
    java基础
  • 原文地址:https://www.cnblogs.com/apollokk/p/6713799.html
Copyright © 2020-2023  润新知