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

转载于:https://www.cnblogs.com/apollokk/p/6713799.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值