想要获得输入密钥,以触发使用jqgrid搜索
我正在使用JQgrid,我总是打开搜索对话框。我希望按下回车键开始搜索。我尝试了一些其他的解决方案,比如在搜索中使用onbeforeshowseach方法,但是随后它会摆脱我总是打开的搜索框。任何人都可以帮我解决这个问题吗?这是我的网格,搜索对话框代码:想要获得输入密钥,以触发使用jqgrid搜索
//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();
回答:
我回答这个问题here。相应的演示是here。我猜想每次搜索都不容易找到答案,因为“搜索”,“对话”和“输入”这些词太常见了。
以上是 想要获得输入密钥,以触发使用jqgrid搜索 的全部内容, 来源链接: utcz.com/qa/260524.html