jqGrid navigator - 如何在全局范围内指定设置? [英] jqGrid navigator - how to specyfy settings globally?

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

问题描述

我正在使用 NavigatorjqGrid 我一遍又一遍地重复设置,例如:

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 navigator - 如何在全局范围内指定设置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆