Jess Stone
Jess Stone

Reputation: 677

JqGrid - clear toolbar filters hitting ESC?

How can I clear all my filters (in JqGrid for PHP) by hitting the key: ESC ?

Upvotes: 1

Views: 1437

Answers (2)

hugo
hugo

Reputation: 86

with jQuery fork perfectly for me slightly modified code

$('#jqxgrid').keyup(function (e) {
    if (e.keyCode === 27) {
      $('#jqxgrid').jqxGrid('clearfilters');
      return false;
    }
});

Upvotes: 0

lonewolf217
lonewolf217

Reputation: 629

Combination of these two links: one and two

Shows there is an event "clearToolbar" which can accomplish this.
I do not use the php version of jqgrid personally so i cannot test it, but from maninpulating the demo code i think this would work.

$search = << < SEARCH
$(document).keyup(function (e) {
    if (e.keyCode === 27) {
        jQuery('#grid')[0].clearToolbar();
        return false;
    }
});
SEARCH;
$grid - > setJSCode($search);

Upvotes: 5

Related Questions