The grid with the options below with the filtertoolbar works fine when you comment out the ‘sopt’ options but not with the options uncommented
I put up a jsfiddle here. In my real grid I have cmTemplate specifed outside all my grids in a $.extend($.jgrid.defaults,{}) -it still causes the same problem
$('#Table').jqGrid({
cmTemplate: {
searchoptions: {
// sopt: ['eq', 'ne', 'cn'] //un comment this line then run again and try to use filtere to see the difference
}
},
datatype: 'local',
data: [{
Code: 'code1'},
{
Code: 'code2'},
{
Code: 'code3'}],
colNames: ['Code'],
colModel: [{
name: 'Code',
index: 'Code'}],
pager: '#Pager'
}).jqGrid('filterToolbar', {
searchOnEnter: false,
defaultSearch: 'cn'
}).trigger('reloadGrid');
I don’t see any problems in the code. If you set
you add
searchoptions.soptin all columns which don’t has the setting. Toolbar filtering can use only one searching operation per column. jqGrid usesdefaultSearchparameter offilterToolbarfor the searching, but to be able to have another searching operation for some columns it can be overwritten from the first operation ofsearchoptions.soptarray (see the answer for example).It is very important feature because which really required.
So including
searchoptions: { sopt: ['eq', 'ne', 'cn'] }option in all columns overwrite practically the optiondefaultSearch: 'cn'offilterToolbartodefaultSearch: 'eq'. Exactly in the way work the demo which you posted.