I'm using jqGrid Filter Toolbar. I'm testing it with 2 columns, one numeric and the other alphanumeric.
All filter operations through the Filter Toolbar are made using the 'bw' (begins with) operator.
How can I set the operation I want to be performed by column?
In this case I want to perfor a 'eq' on the numeric column and a 'cn' on the alphanumeric.
btw, if I use the advanced search dialog everything works correctly.
Thanks!
Here's my implementation:
$('#EntityListGrid').jqGrid({
url: '<%= ResolveUrl("~/Controls/EntityManager/Controllers/EntitiesController.ashx?method=GridDataList") %>',
datatype: 'json',
mtype: 'GET',
colNames: ['ID', 'Name', 'Actions'],
colModel: [
{ name: 'EntityID', index: 'EntityID', width: 50, align: 'left', resizable: true, sortable: true, sopt:['eq'] },
{ name: 'Name', index: 'Name', width: 250, align: 'left', resizable: true, sortable: true },
{ name: 'act', index: 'act', width: 75, sortable: false, search: false },
],
pager: $('#EntityListGridPager'),
rowNum: 10,
rowList: [10, 20, 30],
sortname: 'EntityID',
sortorder: 'desc',
viewrecords: true,
imgpath: '',
caption: 'Entities',
width: EntityListGridWidth,
height: 400,
gridComplete: function () {
var ids = jQuery("#EntityListGrid").jqGrid('getDataIDs');
var editImageUrl = '<%=Page.ResolveUrl("~/Controls/EntityManager/Images/edititem.GIF")%>';
for (var i = 0; i < ids.length; i++) {
var cl = ids[i];
ce = "<img src='" + editImageUrl + "' onclick='EditEntity(" + cl + "); return false;' />";
ce2 = "<input type='button' value='details' src='" + editImageUrl + "' onclick='EditEntity(" + cl + "); return false;' />";
$("#EntityListGrid").setRowData(ids[i], { act: ce2 });
}
}
}).navGrid('#EntityListGridPager', { search: true, edit: false, add: false, del: false, searchtext: "Search" }, {}, {}, {}, { closeOnEscape: true, multipleSearch: true, closeAfterSearch: true });
$('#EntityListGrid').jqGrid('filterToolbar', { stringResult: true, searchOnEnter: false });
you can use sopt property in the corresponding column definition. It can be sopt:['eq']
and sopt:['cn']
in your case. The setting will overwrite the search operator for the selected column only.
The usage of sopt:['eq']
property is sometime really required. For example if you have the column with the option stype:'select', edittype:'select', formatter:'select'
.
UPDATED: Correct setting is searchoptions:{sopt: ['eq']}
and not sopt: ['eq']
. Read the documentation about it.