jqGrid navGrid 搜索提交上 Enter 按键不起作用 [英] jqGrid navGrid search submit on Enter keypress not working
问题描述
我希望能够在按下Enter/Return"键时调用搜索对话框上的查找按钮.不幸的是,'savekey' 选项不会提交表单,与编辑和添加表单编辑的方式相同.
I'd like to be able to invoke the find button on the search dialog when the "Enter/Return" key is pressed. Unfortunately the 'savekey' option doesn't submit the form and the same way it does in the edit and add Form Editing.
这是我正在使用的代码片段.
Here's a snippet of the code I'm using.
$("#list").jqGrid('navGrid', '#pager',
{edit: true, add: true, del: true, search: true, view: true},
...
{
caption: "Search",
closeAfterSearch: true,
closeOnEscape: true,
sopt: ['cn','eq'],
savekey: [true, 13]
},
这是我查阅过的 form_editing 文档的链接:
Here's a link to the form_editing documentation I've consulted:
http://www.trirand.com/jqgridwiki/doku.php?id=wiki:form_editing&s[]=savekey
这里是单字段搜索文档的链接:
Here's a link to the Single field searching documentation:
http://www.trirand.com/jqgridwiki/doku.php?id=wiki:singe_searching&s[]=navgrid
我找不到任何表明此功能存在的信息,但我似乎很容易.一如既往,非常感谢任何帮助或指导.
I can't find anything to suggest this feature exists but I seems like a no-brainer. As always, any help or direction is greatly appreciated.
推荐答案
在我看来,如果你把 savekey: [true, 13]
选项替换掉,这个问题就可以解决了搜索以下 beforeShowSearch 和 onClose 事件句柄
It seems to me that the problem cam be solved if you replace savekey: [true, 13]
option which really not work for searching to the following beforeShowSearch and onClose event handle
beforeShowSearch: function(form){
form.keydown(function(e) {
if (e.which == 13) {
$(".ui-search", form).click();
}
});
},
onClose: function(form){
form.unbind('keydown');
}
This method will work not only for the single field searching but for advance searching also.
如果您希望Enter"键仅在输入字段中起作用,您可以将 form.keydown
替换为 $('.vdata',form).keydown
并在unbind
中进行相应的修改.
If you want that the 'Enter' key work only in the input fields you can replace form.keydown
to $('.vdata',form).keydown
and make the corresponding changes in the unbind
.
这篇关于jqGrid navGrid 搜索提交上 Enter 按键不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!