My jqGrid uses loadonce: true and has a pair of columns I'm trying to filter by. 'DeletedFlag' is a hidden column with a bit flag. The column 'Deleted?' is visible and displays either nothing (DeletedFlag == 0) or a timestamp (DeletedFlag == 1).
Is there a way to map the filter input from 'Deleted?' to 'DeletedFlag' as I have attempted in the code sample below? If not, is there a way to change the 'Deleted?' editoptions->value string to enable filtering by either an empty or non-empty string?
{ name: 'DeletedFlag', index: 'DeletedFlag', hidden: true, searchoptions: { sopt: ['eq'], searchhidden: true }},
{
name: 'Deleted?', index: 'DeletedFlag', width: 70, sortable: false, editable: false,
stype: 'select', /*edittype: 'checkbox',*/ searchoptions: { value: ':All;0:No;1:Yes' }
}
EDIT: posting the entire grid + test data
$(function () {
var grid = $("#PSGrid");
// get values from Products table
var prodValues = $.ajax({
url: "jqGridHandler.ashx?oper=pVals",
async: false,
success: function (data) {
}
}).responseText;
// get values from Environments table
var envValues = $.ajax({
url: "jqGridHandler.ashx?oper=eVals",
async: false,
success: function (data) {
}
}).responseText;
// get values from ServerTypes table
var typeValues = $.ajax({
url: "jqGridHandler.ashx?oper=tVals",
async: false,
success: function (data) {
}
}).responseText;
var lastsel = -1;
// build the grid
grid.jqGrid({
url: 'jqGridHandler.ashx',
editurl: 'jqGridEditor.ashx',
datatype: 'json',
height: 550,
width: 'auto',
colNames: ['ID', 'Product', 'Environment', 'Hostname', 'IP', 'Description', 'Type', 'Ports Used', 'DeletedFlag', 'Deleted?'],
colModel: [
{ name: 'ID', index: 'ID', width: 50, sortable: true, hidden: true, editable: false, key: true, sorttype: 'int' },
{
name: 'Product', index: 'Product', width: 125, sortable: true, editable: true,
stype: 'select', searchoptions: { value: ':All;' + prodValues, sopt: ['eq'] },
formatter: 'select', edittype: 'select', editoptions: { value: prodValues },
editrules: { required: true }
},
{
name: 'Environment', index: 'Environment', width: 100, sortable: true, editable: true,
stype: 'select', searchoptions: { value: ':All;' + envValues, sopt: ['eq'] },
formatter: 'select', edittype: 'select', editoptions: { value: envValues },
editrules: { required: true }
},
{
name: 'Hostname', index: 'Hostname', width: 200, sortable: true, editable: true,
editrules: { required: true }
},
{
name: 'IP', index: 'IP', width: 125, sortable: false, editable: true
},
{
name: 'Description', index: 'Description', width: 200, sortable: true, editable: true,
editrules: { required: true }
},
{
name: 'Type', index: 'Type', width: 75, sortable: true, editable: true,
stype: 'select', searchoptions: { value: ':All;' + typeValues, sopt: ['eq'] },
formatter: 'select', edittype: 'select', editoptions: { value: typeValues },
editrules: { required: true }
},
{ name: 'Ports Used', index: 'Ports Used', width: 80, sortable: false, editable: true },
{ name: 'DeletedFlag', index: 'DeletedFlag', hidden: true, searchoptions: { sopt: ['eq'], searchhidden: true }},
{
name: 'Deleted?', index: 'Deleted?', width: 70, sortable: false, editable: false,
stype: 'select', /*edittype: 'checkbox',*/ searchoptions: { value: ':All;0:No;1:Yes' }
}
],
rowNum: 10000, // show all rows hack (-1 is the proper way to do it but is bugged in this version of jqGrid)
pager: '#PSGridPager',
sortname: 'ID',
pgbuttons: false,
pgtext: null,
viewrecords: false,
sortorder: 'asc',
ignoreCase: true,
caption: 'Click a row to edit. [Enter] to save, [Esc] to cancel.',
loadonce: true,
onSelectRow: function (id) {
if (id && id !== lastsel) {
grid.jqGrid('restoreRow', lastsel);
grid.jqGrid('editRow', id, true);
lastsel = id;
}
},
afterSubmit: function (response, postdata) {
$(this).jqGrid('setGridParam', { datatype: 'json' });
alert('hello');
return [true];
}
});
grid.jqGrid('filterToolbar', { stringResult: true, searchOnEnter: true, defaultSearch: "cn" });
grid.jqGrid('navGrid', '#PSGridPager', { edit: false, add: true, del: true, search: false, refresh: true, paging: false },
{ /* edit options */ },
{ /* add options */
closeOnEscape: true,
closeAfterAdd: true,
reloadAfterSubmit: true,
width: 400
},
{ /* delete options */
closeOnEscape: true,
reloadAfterSubmit: true
});
grid.jqGrid('navButtonAdd', '#PSGridPager', {
caption: "Export to Excel",
onClickButton: function () {
grid.jqGrid('excelExport', { url: "jqGridHandler.ashx" });
}
});
});
Typical row (comma delimited):
'A4', 'Test/QA', 'BLDALTSGPOOFF04', '192.168.86.190', 'IIS 7 Web Farm', 'Web', '80', ''