I am using JQgrid and I have the search dialog always open. I would like to have the enter key start the search when it is pressed. I have tried some other solutions like using the onbeforeshowseach method in the search but then it gets rid of my always open search box. Can anyone help me figure this out? Here is my grid and search dialog code:
//Create the grid
var grid = $("#list"), prmSearch = { multipleSearch: false, overlay: false };
var url = window.URLS.get('MySample');
$("#list").jqGrid({
url: url,
datatype: 'json',
mtype: 'POST',
postData: {
ignoreCurrentSelectionPage: function () { return ignoreCurrentSelectionPage; },
groupNo: '<%= ViewBag.value1%>',
groupType: '<%= ViewBag.value2%>'
},
colNames: ['Col1', 'Col2', 'Col3','Col4', 'Col5','Col6', 'Col7'],
colModel: [
{ name: 'Col1', index: 'Col1', width: 300, align: 'center', hidden: true },
{ name: 'Col2', index: 'Col2', width: 250, align: 'left', search: true, searchoptions: { sopt: ['bw', 'ew','cn','eq', 'ne' ]} },
{ name: 'Col3', index: 'Col3', width: 240, align: 'left' , search: true, searchoptions: { sopt: ['bw', 'ew','cn','eq', 'ne' ]}},
{ name: 'Col4', index: 'Col4', width: 100, align: 'center', search: false },
{ name: 'Col5', index: 'Col5', width: 100, align: 'center', search: false },
{ name: 'Col6', index: 'Col6', width: 100, align: 'center', search: false },
{ name: 'Col7', index: 'Col7', editable: true, edittype: 'checkbox', editoptions: { value: "yes:no" },search:false,
formatter: "checkbox", formatoptions: { disabled: false }, align: 'center', width: 50
},
],
pager: jQuery('#pager'),
rowNum: 15,
rowList: [10, 15, 25, 50, 100, 500],
sortname: 'Col2',
sortorder: "asc",
viewrecords: true,
multiselect: false,
multikey: "ctrlKey",
caption: 'Sample',
width: "100%",
height: "100%",
loadError: function (xhr, textStatus, errorThrown) {
},
gridComplete: function () {
prmSearch = { multipleSearch: true, overlay: false };
ignoreCurrentSelectionPage = true;
$("#list").setSelection(selectedRowId, true);
},
}).navGrid('#pager',
{ edit: false, add: false, del: false, search: true, refresh: true },
{}, // default settings for edit
{}, // default settings for add
{}, // delete instead that del:false we need this
{overlay:0}, // search options
{}, /* view parameters*/
prmSearch);
// create the searching dialog
grid.searchGrid(prmSearch);
// find the div which contain the searching dialog
//var searchDialog = $("#searchmodfbox_" + grid[0].id);
var searchDialog = $("#searchmodfbox_" + grid[0].id);
// make the searching dialog non-popup
searchDialog.css({ position: "relative", "z-index": "auto"});
searchDialog.addClass("ui-jqgrid ui-widget ui-widget-content ui-corner-all");
searchDialog.css({ position: "relative", "z-index": "auto", float: "left"});
var gbox = $("#gbox_" + grid[0].id);
gbox.before(searchDialog);
gbox.css({ clear: "left"});
//remove the empty span in the search dialog box.
//we may need to re-add this is advanced searching is turned on
$("#fbox_list").find('span:empty').parent().remove();
//remove the empty span in the search dialog box.
//we may need to re-add this is advanced searching is turned on
$("#fbox_list").find('span:empty').parent().remove();