问题描述
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.nav
,jQuery.jgrid.del
,jQuery.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:true
,add:true
,del:true
已经是默认设置(请参见 navGrid的源代码)
The settings edit:true
, add:true
, del:true
are already default (see the source code of navGrid)
这篇关于jqGrid导航器-如何全局指定设置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!