EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: Pierre on November 21, 2016, 07:31:27 AM



Title: [SOLVED] DataGrid Filter WildCard
Post by: Pierre on November 21, 2016, 07:31:27 AM
Hello all
is it possible to use DataGrid filter Extension with WildCard?
For example, if I have DataGrid column "Name" with rows:
abc 123
abc 123456
abc 456

and if I use WildCard search string, like:
abc *45*

it should return second and third row.
Thank you.



Title: Re: DataGrid Filter WildCard
Post by: stworthy on November 21, 2016, 05:19:54 PM
You can extend a new operator 'wildcard' and then set it as the default filter operator.
Code:
$.extend($.fn.datagrid.defaults.operators, {
wildcard: {
text: 'Wildcard',
isMatch: function(source, value){
source = String(source);
value = String(value);
// return source.toLowerCase().indexOf(value.toLowerCase()) >= 0;
// if matched return true, otherwise return false
}
}
});
$.extend($.fn.datagrid.defaults, {
defaultFilterOperator: 'wildcard'
});


Title: Re: DataGrid Filter WildCard
Post by: Pierre on November 22, 2016, 12:46:26 AM
Thank you so much but I don't know how to return only matched values.
For example, if I have values in the datagrid:
abc 123
abc 123456
abc 456

and if start to type:
abc 45

how to return only second and third row?
Do you have some example, please?


Title: Re: DataGrid Filter WildCard
Post by: stworthy on November 23, 2016, 12:20:01 AM
Please look at this example http://code.reloado.com/oliviw/edit#preview


Title: [SOLVED] Re: DataGrid Filter WildCard
Post by: Pierre on November 23, 2016, 01:58:18 AM
Just perfect.
thank you so much  ;D