JQgridを使用していて、検索ダイアログを常に開いています。エンターキーを押したときに検索を開始してもらいたいのですが。検索でonbeforeshowseachメソッドを使用するなど、他の解決策をいくつか試しましたが、常に開いている検索ボックスが削除されます。誰かが私がこれを理解するのを手伝ってもらえますか?これが私のグリッドと検索ダイアログのコードです:
//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();