It's really easy to do. You should just understand that the code for creating jqGrid look like
$("#gridid").jqGrid(objectWithGridOptions);
One use mostly anonymous inline object initialization like
$("#gridid").jqGrid({
// ... some options
});
but it do nothing more as
var objectWithGridOptions = {
// ... some options
};
$("#gridid").jqGrid(objectWithGridOptions);
So if you want to create multiple grids
$("#gridid1").jqGrid({
// ... some common options
// ... some options specific for grid 1
});
$("#gridid2").jqGrid({
// ... some common options
// ... some options specific for grid 2
});
$("#gridid3").jqGrid({
// ... some common options
// ... some options specific for grid 3
});
then you can define the object with common options and extend it using $.extend to the specific object for the grid. In the way you can even overwrite some common options. So if you use some option in grid 1 and grid 2, but not in grid 3 you can still include the most common option in the common object and just include the new value during creating of the grid 3.
The code can look like
// the part can be in separate js file which you includes
// on all pages of your project
var commonModuleOption = {
// ... some common options
};
$("#gridid1").jqGrid($.extend(true, {}, commonModuleOption, {
// ... some options specific for grid 1
});
$("#gridid2").jqGrid($.extend(true, {}, commonModuleOption, {
// ... some options specific for grid 2
});
$("#gridid3").jqGrid($.extend(true, {}, commonModuleOption, {
// ... some options specific for grid 3
});