I figured out what's going on. This is what my code looks like:
var dg = $('#dg').datagrid({
filterBtnIconCls:'icon-filter'
});
dg.datagrid('enableFilter', [{
field:'listprice',
type:'numberbox',
options:{precision:1},
op:['equal','notequal','less','greater']
},{
field:'unitcost',
type:'numberbox',
options:{precision:1},
op:['equal','notequal','less','greater']
},{
field:'status',
type:'combobox',
options:{
panelHeight:'auto',
data:[{value:'',text:'All'},{value:'P',text:'P'},{value:'N',text:'N'}],
onChange:function(value){
if (value == ''){
dg.datagrid('removeFilterRule', 'status');
} else {
/*dg.datagrid('addFilterRule', {
field: 'status',
op: 'equal',
value: value
});*/
}
dg.datagrid('doFilter');
}
},
op:['equal','notequal']
}]);
dg.datagrid('addFilterRule', {
field: 'status',
op: 'notequal',
value: 'N'
});
It's the last block of code that I'm expecting to filter out 'N':
dg.datagrid('addFilterRule', {
field: 'status',
op: 'notequal',
value: 'N'
});
...and it does. It's just that this triggers a change, and if you look a few lines above at the onChange event handler in the status column, you see this:
if (value == ''){
dg.datagrid('removeFilterRule', 'status');
} else {
dg.datagrid('addFilterRule', {
field: 'status',
op: 'equal',
value: value
});
}
value is not '' so it goes into the else and sets the filter operator to 'equal', essentially overriding my 'notequal'.
So I commented that section out and now it works like a charm.