Jq Grid Search On Enter If Search Box Is Always Visible On Page
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 poppe
Solution 1:
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' eventvar 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).
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.
Post a Comment for "Jq Grid Search On Enter If Search Box Is Always Visible On Page"