Similar questions to this have been asked here before but I haven't had any success using those answers in my scenario.
I have a grid with datatype: 'local', and loadonce: true. In 3 of my columns I use a custom formatter.
The first one takes a timestamp in milliseconds and displays a time in the form of "H:MM am" (eg, 8:35 am, 12:19 pm). I'll omit that code as I'm sure it's not relevant.
The second customer formatter takes an integer and returns a string indicating which days of the week the number represents. It uses bitwise operations where 1 is Sunday, 2 is Monday, 4 is Tuesday, 8 is Wed, etc. So the number 67 represents Sunday, Monday, and Saturday (1+2+64), so the formatter returns "SMSa"
function daysOfWeekFormatter(daysMask, options, rowObject) {
var days='';
if ((daysMask & 1) != 0) days+="S";
if ((daysMask & 2) != 0) days+="M";
if ((daysMask & 4) != 0) days+="T";
if ((daysMask & 8) != 0) days+="W";
if ((daysMask & 16) != 0) days+="Th";
if ((daysMask & 32) != 0) days+="F";
if ((daysMask & 64) != 0) days+="Sa";
return days;
}
The third custom formatter is very simple, it just returns a string is a boolean is false, and nothing if it's true:
function closedFormatter(isOpen, options, rowObject) {
return isOpen ? '' : 'Closed';
}
Here is my jqgrid call.
$("#jqgrid").jqGrid({
colModel: [
{ name: 'timeField', label: 'Time', index: 'timeField', width: 100, formatter: timeFormatter},
{ name: 'daysOfWeek', label: 'Days of the Week', formatter: daysOfWeekFormatter},
{ name: 'openClosed', label: 'CLOSED', formatter: closedFormatter}
],
datatype: 'local',
loadonce: true,
scrollOffset: 0,
viewrecords: false,
rowNum: -1
});
$("#jqgrid").jqGrid("filterToolbar", {stringResult: true, searchOnEnter: false, defaultSearch: "cn"});
In the column filters, I want users to be able to just type what they see in the table and get those filtered. For example, if they type "F" in the days of week, they see all the rows including F. "S" would yield the saturday and sunday rows.
Any ideas how this can be done? I'd like to write a function that gets called for every row with the typed in filter and I can return true or false. Does jqgrid provide anything like this? Thanks!