I have 10 jqgrids in an ASP.NET webpage and each of them display different data to the user.
Except colNames, colModel, pager and sortname properties, all other properties the are same. See my code below,
datatype: "local",
mtype: "GET",
cmTemplate: { sortable: true, resizable: true },
height: 'auto',
altRows: true,
altclass: '',
pgbuttons: false,
pgtext: "",
gridview: true,
loadonce: true,
shrinkToFit: false,
pager: gridPager,
autoencode: true,
sortname: 'Id',
width: $('.grid-wrapper').width() - 20,
emptyrecords: 'No records found',
viewrecords: true,
sortorder: "desc",
scrollrows: true,
loadui: 'disable',
toppager: true,
Is it possible to put all of the above properties in a common variable and reuse the variable in all the 10 different grid's?
The idea is to save some space and make the changes in one place.
Note: I am using jqgrid plugin 4.6.0.
Solution Applied:
Added the following code to the top of my js file and removed the same properties from all the 10 jqgrids. Working great!
//DEFAULTS
$.extend($.jgrid.defaults, {
datatype: "local",
mtype: "GET",
cmTemplate: { sortable: true, resizable: true },
height: 'auto',
altclass: '',
pgbuttons: false,
pgtext: "",
gridview: true,
loadonce: true,
shrinkToFit: false,
autoencode: true,
emptyrecords: 'No records found',
viewrecords: true,
sortorder: "desc",
scrollrows: true,
loadui: 'disable'
});