tags:

views:

59

answers:

1

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] 
    },

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.

A: 

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.

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.

Oleg
This totally makes sense. I'll have to give it a try. Thanks for the help.
gurun8
Worked like a dream.
gurun8