EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: rezzonico on November 09, 2023, 08:58:26 AM



Title: datagrid + enableFilter
Post by: rezzonico on November 09, 2023, 08:58:26 AM
Hi,

I have a datagrid with "enableFilter". In the filter, I have a combobox with the property "multiple: true".
If you select a line in the combobox, an error is received in the console.
How can I avoid this ?

See the code here:
http://217.193.156.220/BBB/


Thanks
Miche


Title: Re: datagrid + enableFilter
Post by: jarry on November 14, 2023, 01:32:01 AM
Please extend a new operator to filter multiple values.
Code:
$.extend($.fn.datagrid.defaults.operators, {
    mequal: {
        text: 'Equal',
        isMatch: function (source, value) {
            const vv = value.split(',');
            const index = vv.indexOf(source);
            return index != -1;
        }
    }
})

And then apply it to your code.
Code:
onChange: function (value) {
    if (value == '') {
        dg_HW.datagrid('removeFilterRule', 'Year');
    } else {
        dg_HW.datagrid('addFilterRule', {
            field: 'Year',
            op: 'mequal',
            value: value.join(',')
        });
    }
    dg_HW.datagrid('doFilter');
}


Title: Re: datagrid + enableFilter
Post by: rezzonico on November 14, 2023, 04:26:12 AM
Thanks !

Regards
Miche