开发者

Create base jqgrid

开发者 https://www.devze.com 2023-02-16 03:29 出处:网络
I have a website with several views, and most of them have a jqGrid on them. I\'d like to set some base options on all my jqgrids.For example, I\'d like the view option to always be set to true, and

I have a website with several views, and most of them have a jqGrid on them.

I'd like to set some base options on all my jqgrids. For example, I'd like the view option to always be set to true, and the search option to always be set to false.

Additionally, there are several that I'd开发者_运维技巧 like to have the same button labels.

Is there any way to do this with a jqGrid?


Look at the answer which shows how to set default settings jQuery.jgrid.nav. In your case it would be

jQuery.extend(jQuery.jgrid.nav,
    {search:false,view:true, viewtext:"View label", viewtitle:"View tooltip"}
);

Other default settings you can change in the same way using jQuery.jgrid.del, jQuery.jgrid.view and of course jQuery.jgrid.defaults.

You don't need to place the code inside of jQuery(document).ready(function() {/**/});. It is enough just ecxecute the code like jQuery.extend(jQuery.jgrid.nav, {search:false,view:true}); inside a JavaScript file loaded after the jquery.jqGrid.min.js.


You could add an additional script tag to your HTML that references a JS file with some base configuration stuff for the grid in a $().ready(function() {}); block.

You could also create a base configuration function or variable that you store in that external JS, and reference that configuration on each view page.

I would prefer to write the base function, and not the ready event handler as the ready handler will NOT run at a predictable time. You won't know if it properly ran before your jqGrid configure function ran.

0

精彩评论

暂无评论...
验证码 换一张
取 消