I have a jqGrid:
$('#jqgFileInfoList').jqGrid({
url: '@Url.Action("GetFiles", "File")',
datatype: 'json',
mtype: 'POST',
colNames: ['Id', 'Name', 'Interface', 'Amount', 'Type', 'Created', 'Status'],
colModel: [
{ jsonmap: 'Id', name: 'Id', formatter: 'integer', align: 'right', hidden: true },
{ jsonmap: 'Name', name: 'Name', align: 'right', hidden: true },
{ jsonmap: 'InterfaceName', name: 'InterfaceName', align: 'left', width: '100%', sorttype: 'text', frozen: true, search: true },
{ jsonmap: 'Amount', name: 'Amount', formatter: 'currency', align: 'right', width: '100%', sorttype: 'number', search: true },
{ jsonmap: 'Type', name: 'Type', align: 'right', width: '100%', sorttype: 'text', search: true },
{ jsonmap: 'RunDate', name: 'RunDate', formatter: 'date', align: 'right', width: '100%', sorttype: 'date', search: true },
{ jsonmap: 'Status', name: 'Status', align: 'right', width: '100%', sorttype: 'text', formatter: formatStatus, search: true }
],
sortname: 'RunDate',
sortorder: 'desc',
pager: $('#jqgPagerFileInfoList'),
rowNum: 5,
viewrecords: true,
height: '100%',
autowidth: true,
refresh: true,
ignoreCase: true,
jsonReader: {
repeatitems: false,
root: "rows"
},
altRows: true,
altclass: 'jqGridAltRow',
loadComplete: function () {
$("tr.jqgrow:odd").addClass('jqGridAltRow');
}
});
$('#jqgFileInfoList').jqGrid('filterToolbar', { searchOnEnter: false, enableClear: true, stringResult: true });
Filtering is working, except for a couple columns I want to modify.
The Created/RunDate column I would like to filter a range somehow. Picking a single date is not useful.
The Interface, Type and Status columns I would like to use drop downs. What's the best way to do this?
I find the jqGrid documentation VERY difficult to follow, there are just so many options. It took me an hour to figure out that I needed stringResult: true
to get my filter options into the GridSettings.Where
property in the controller.
And if it matters, it's a .Net 4.0, MVC app.
EDIT: Bonus Question: How do I make it case insensitive.