navGrid搜索在输入按键上提交不起作用

navGrid搜索在输入按键上提交不起作用

本文介绍了jqGrid navGrid搜索在输入按键上提交不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够在按下"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[]=保存键

以下是指向单一字段"搜索文档的链接:

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搜索在输入按键上提交不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 09:31