jqGrid navGrid search submit on Enter keypress not working

后端 未结 4 419
我在风中等你
我在风中等你 2020-12-22 00:12

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

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-22 00:41

    Try the following code. Works for me:

    beforeShowSearch: function(form){
       $(form).keydown(function(e) {
          if (e.keyCode == 13) {
             setTimeout(function() {
                $("#fbox_cust_grid_search").click();
             }, 200);
          }
       });
       return true;
    },
    onClose: function(form){
       $("#fbox_cust_grid_search").unbind('keydown');
    }
    

    There seems to be an issue when the click method is called too quickly. Giving the grid 200ms to do what it has to do before searching seems to do the trick.

提交回复
热议问题