本文介绍了jqGrid导航器-如何全局指定设置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将导航器 jqGrid ,我在重复这样的设置:

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?

我知道如何全局指定jqGrid设置,但是导航器出现问题.我的样本Navigator定义如下:

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
        }
    );

推荐答案

对象jQuery.jgrid.edit负责添加"和编辑"表单的默认设置,因此可以在通用JavaScript代码中包含以下内容:

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
});

如果在编辑"或添加"表单中使用某些事件,我建议您使用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.

其他设置jQuery.jgrid.navjQuery.jgrid.deljQuery.jgrid.view,当然还有jQuery.jgrid.defaults也会很有帮助,并且可以与上述jQuery.jgrid.edit相同的方式使用.例如,

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});

设置edit:trueadd:truedel:true已经是默认设置(请参见 navGrid的源代码)

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

这篇关于jqGrid导航器-如何全局指定设置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 05:19