I need to set the default column selection on a jqGrid single-search dialog.
The options available are described on the jqGrid wiki
To set the default search "type" option, I re-ordered the "sopt" array with the value I need ("contains", "cn") first in the array and set this on the navGrid
search options. Despite browsing the source code I have not been able to work out which property might affect the initial field selection. It always defaults to the first column in my colModel
.
My code is:
$('#tableid').jqGrid({
colNames: ['ID', 'Membership#', 'Join Date', 'Email', 'Name', 'Address', 'Postcode'],
colModel: [
{name:'ID', index:'ID', hidden:true },
{name:'MEMID', index:'MEMD', width:90 },
{name:'JOINDATE', index:'JOINDATE', width:70 },
{name:'EMAIL', index:'EMAIL', width:150, align:"right" },
{name:'NAME', index:'NAME', width:120, align:"right" },
{name:'ADDRESS', index:'ADDRESS', width:250, align:"right" },
{name:'POSTCODE', index:'POSTCODE', width:80, align:"right" }
],
// etc. ...
});
$("#tableid").jqGrid('navGrid', '#pager',
{ /* parameters */
edit:false, add:false, del:false, searchtext:'Find ', refreshtext:'Refresh '
},
{ /* edit options */ },
{ /* add options */ },
{ /* delete options */ },
{ /* search options */
multipleSearch:false,
multipleGroup:false,
showQuery:false,
top: 190,
left: 200,
caption: "Search for members...",
closeAfterSearch: false,
sopt: ['cn','nc','eq','ne','lt','le','gt','ge','bw','bn','in','ni','ew','en'],
},
{ /* view options */ }
);
When the user clicks on "Find" I would like the initial default search dialog to be presented with "Name", "contains" selected.
See Question&Answers more detail:
os