0

I had these working great as navgrid settings like follows:

this.Grid.navGrid('#' + this.PagerId, {}, {}, {}, {},
{         
    closeAfterSearch: true,
    closeAfterReset: true,
    closeOnEscape: true      
});

but I would like them to be set as defaults.

I tried:

  • $.extend($.jgrid.defaults, { search : { closeAfterReset: true } });
  • $.extend($.jgrid.search, { closeAfterReset: true } );

...and neither seem to be working. Any tips?

EDIT:

Here is my code as @Oleg suggested - still not working:

$.extend($.jgrid.search, {    
            closeAfterSearch: true,
            closeAfterReset: true,
            closeOnEscape: true,
            beforeShowSearch: function ($form) {
            ...
            },
            onClose: function (searchBoxId) {
             ...
            },
            Reset: "Clear Filter",
            Find: "Filter Grid"
        });

According to the single_searching article on the jqgrid wiki, search options are set here, which is why I did my original code:

<script>
...
jQuery("#grid_id").jqGrid({
 ...
pager : '#gridpager',
...
}).navGrid('#gridpager',{view:true, del:false}, 
{}, //  default settings for edit
{}, //  default settings for add
{},  // delete instead that del:false we need this
{search_options}, // search options  
{} /* view parameters*/
);
...
</script>

The funny thing to me is that my onClose and beforeShowSearch events are being hit, but the properties are having now affect...

IronicMuffin
  • 4,182
  • 12
  • 47
  • 90

1 Answers1

1

The default searching settings should be set by

$.extend($.jgrid.search,
    {closeAfterSearch: true, closeAfterReset: true, closeOnEscape: true});

I don't tested exactly such settings, but my standard settings

$.extend(
    $.jgrid.search,
    {
        multipleSearch: true,
        multipleGroup: true,
        recreateFilter: true,
        closeOnEscape: true,
        overlay: 0
    }
);

work perfect.

It should be executed after jqGrid js-files and before the navGrid call. The syntax this.Grid.navGrid which you use seems me a little strange.

Oleg
  • 220,925
  • 34
  • 403
  • 798
  • I'll give this a shot. The syntax `this.Grid.navGrid` is my own construct. I'm attempting to create a standard "widget" for use in my corporation, so I've created an object that contains the jquery grid selector as a property as a shortcut. This is why I'm seeking to default as much functionality as I can. My goal is to only have to code a model and any extra functionality required for each grid we create, with a standard look and feel across every application. – IronicMuffin Sep 01 '11 at 20:41
  • @IronicMuffin: I just found that this your answer is still unsolved. So I modified a little my demo from [the answer](http://stackoverflow.com/questions/7394033/how-can-i-closeafterreset-using-single-search-on-jqgrid/7394598#7394598): [The new demo](http://www.ok-soft-gmbh.com/jqGrid/CloseAfterReset1.htm) set properties and I see no problems. – Oleg Sep 12 '11 at 22:16
  • Looks good. As you saw in the [other question](http://stackoverflow.com/questions/7394033/how-can-i-closeafterreset-using-single-search-on-jqgrid/7394598#7394598) I asked, I realized that closeOnReset is not functioning properly in jqGrid. Marked as answer. Thanks! – IronicMuffin Sep 13 '11 at 12:31