1

I'm using Navigator with jqGrid and I'm repeating over and over settings such as:

savekey: [true, 13],
closeOnEscape: true,
closeAfterAdd: true

How can I define these settings globally to all my grids on current page?

I know how to specyfiy jqGrid settings globally, but I have problems with Navigator. My sample Navigator definition looks like this:

    $("#dictionaryElementsGrid").navGrid(
        "#dictionaryElementsPager",
        {
            search: false,
            edit: true,
            add: true,
            del: true
        },
        {
            // Edit options:
            savekey: [true, 13],
            closeOnEscape: true,
            closeAfterEdit: true
        },
        {
            // Create options:
            savekey: [true, 13],
            closeOnEscape: true,
            closeAfterAdd: true
        }
    );
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Łukasz Podolak
  • 958
  • 3
  • 12
  • 24

1 Answers1

5

The object jQuery.jgrid.edit is responsible for the default setting of Add and Edit forms, so you can include in your common JavaScript code the following:

jQuery.extend(jQuery.jgrid.edit, {
    savekey: [true, 13],
    closeOnEscape: true,
    closeAfterEdit: true,
    closeAfterAdd: true,
    recreateForm: true
});

The recreateForm:true option is another option which I recommend you to use if you use some events in the Edit or Add form.

Another settings jQuery.jgrid.nav, jQuery.jgrid.del, jQuery.jgrid.view and of course jQuery.jgrid.defaults can be also helpful and can be used in the same way as jQuery.jgrid.edit above. For example,

jQuery.extend(jQuery.jgrid.nav, {search: false});

The settings edit:true, add:true, del:true are already default (see the source code of navGrid)

Oleg
  • 220,925
  • 34
  • 403
  • 798
  • Oleg, This is even more comprehensive answer than I ever expected. Many thanks for your effort. – Łukasz Podolak Feb 18 '11 at 10:21
  • Hello, unfortunately doesn't work: jQuery.extend(jQuery.jgrid.nav, { refresh: true, refreshicon: "custom-icon" }); Tried this before and after I load grid itself, but nothing :( – Grufas Aug 28 '18 at 15:04
  • @LifeIsShort: Which **version** of jqGrid you use and from which fork of jqGrid ([free jqGrid](https://github.com/free-jqgrid/jqGrid), commercial [Guriddo jqGrid JS](http://guriddo.net/?page_id=103334) or an old jqGrid in version <=4.7)? Which CSS framework you use (jQuery UI or Bootstrap)? Which `iconSet` you use? Which CSS rules exist on `custom-icon` class, which you want to use?... A demo, which reproduce the problem, would clear the most questions. – Oleg Aug 28 '18 at 16:44