I’m trying to call jqGrid’s setGridWidth function, but I’m getting the error:
Object [object Object] has no method ‘setGridWidth’
I’m sure this is something stupid. Here’s the code to display the grid (which is fine) and then try to resize it.
$("#jqGridElement").jqGrid({
datastr: tableSrc,
jsonReader: { repeatitems: false },
datatype: "jsonstring",
colNames: ['title', 'subtitle'],
colModel: [
{ name: 'title', index: 'title', width: 55 },
{ name: 'subtitle', index: 'subtitle'}],
height: 'auto',
gridview: true
});
$("#jqGridElement").setGridWidth(600);'
EDIT
I’ve also tried:
var gridObj = $("#jqGridElement").jqGrid({ datastr: tableSrc, .......
gridObj.setGridWidth(300);
Same result
I suppose that you set
$.jgrid.no_legacy_api = true;like I did in my last demos.The “standard” (legacy API) code of jqGrid set many method extensions of jQuery. It’s dangerous in case of usage many other jQuery Plugins. The probability to have name conflicts are increased. So it’s recommended to use “new style” jqGrid API. In case of
setGridWidthmethod you should useinstead of
One small general remark: I recommend you to define
gridObjasinstead of
The advantage is that the value of
gridObjwill be set before the call of$("#jqGridElement").jqGridand you can use safegridObjinside of anyjqGridevent. For example you can usegridObjvariable inside ofloadCompleteevent. In case of usage in the way like you use it now thegridObjvariable can beundefinedat the first usage ofloadCompleteevent.