1

私はjqueryで次のコードを書きました:

$('input[type="text"]').keyup(
    function (event) {
        // Allow: backspace, delete, tab, escape, and enter
        if (event.keyCode != 68 && event.keyCode != 186) return;
        var textbox = $(this);
        var clickAttr = textbox.attr('click');
        if (clickAttr != undefined && clickAttr.indexOf('NumericTextBoxKeyPress') > -1) return; 
        var insertedValue = textbox.val();
        insertedValue = insertedValue.replace(/a/g, 'SampleA');
        insertedValue = insertedValue.replace(/b/g, 'SampleB');
        textbox.val(insertedValue);
    }
);

通常のテキストボックスでは問題ありませんが、上記のコードはjQGridフィルタリングのテキストボックスでは機能しません。

関数をjQGridフィルタリングのテキストボックスにバインドします

キーアップ関数をjQGridフィルタリングのテキストボックスにバインドする方法を教えてください。

4

2 に答える 2

2

グリッドがあり、検索ツールバーの指定された1つの入力フィールドでイベントをバインドする場合は、の対応する列を使用できますdataEventssearchoptionsここcolModelを参照。コード例については、回答を参照してください。

keyupグリッドの検索ツールバーのすべての入力フィールドなどのイベントをバインドする必要がある場合は、次の操作を実行できます。

var $grid = $("#list"); // the grid

// create the grid
$grid.jqGrid({
    //... jqGrid options
});

// create the searching toolbar with the line like
$grid.jqGrid('filterToolbar', {defaultSearch: 'cn'});

// get all input fields of the searching toolbar
var $toolbarRow = $grid.closest(".ui-jqgrid-view")
                       .find(".ui-jqgrid-htable .ui-search-toolbar");

// make the binding of all input fields to the event which you need
$toolbarRow.find('input[type="text"]').keyup(function (e) {
    // the code of your event handler
});
于 2012-09-08T11:47:26.160 に答える
1

jquery live()を使用してイベントをバインドします

 $('input[type="text"]').live("click", function(){ .... });
于 2012-09-08T11:23:09.747 に答える