如果输入框始终在页面上显示,请在Enter上执行jq Grid Search [英] jq Grid Search on Enter if Search Box is always visible on page

查看:69
本文介绍了如果输入框始终在页面上显示,请在Enter上执行jq Grid Search的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是此问题的后续操作可以制作jqGrid搜索框停留在页面上?

This is a followup to this question Possible to make jqGrid Search Box Stay on Page?

如果以正常方式弹出搜索框然后再将其关闭,我在回车键上找到了进行网格搜索的方法,但是,如果始终使用搜索表单,可以使回车键触发搜索可见吗?

I found directions for making the grid search on the enter key if the search box is being popped open and then closing in the normal fashion, but, is it possible to make the enter key trigger a search if the search form is always visible?

为我们中间的文字进行编辑,请问我该怎么做?

Edit for the literal among us, and how would I go about doing so please?

推荐答案

您有可能.我想您仍然使用jqGrid 3.8.2.因此,我将在答案中使用该版本.

You it is possible. I suppose that you still use jqGrid 3.8.2. So I will use the version in my answer.

该解决方案的主要思想可以在

The main idea of the solution you can find in the answer. To be more careful the code of beforeShowSearch should be a little extended:

beforeShowSearch: function($form) {
    // because beforeShowSearch will be called on all open Search Dialog,
    // but the old dialog can be only hidden and not destroyed
    // we test whether we already bound the 'keydown' event
    var events = $('.vdata',$form).data('events'), event;
    for (event in events) {
        if (events.hasOwnProperty(event) && event === 'keydown') {
            return;
        }
    }
    $('.vdata',$form).keydown( function( e ) {
        var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0;
        if (e.which == 13) { // save
            //$(".ui-search", $form).click();
            grid[0].SearchFilter.search();
        }
    });
}

在高级搜索对话框中的工作方式(请参见演示),并在始终位于网格上方的对话框中(请参见另一个演示).

The way works in the advance searching dialog (see the demo) and in the dialog which is always over the grid (see another demo).

更新:从jQuery 1.8开始,应该使用$._data($('.vdata',$form)[0], 'events');而不是$('.vdata',$form).data('events')来获取网格中所有事件的列表.

UPDATED: Starting with jQuery 1.8 one should use $._data($('.vdata',$form)[0], 'events'); instead of $('.vdata',$form).data('events') to get the list of all events of the grid.

这篇关于如果输入框始终在页面上显示,请在Enter上执行jq Grid Search的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆