Reputation: 49
I have an array which contains following elements.
var column = { };
column["name"] = "Id";
column["sorttype"] = 'int';
column["hidden"] = true;
column["editable"] = false;
arr1.push(column);
column["name"] = "Name";
column["sorttype"] = 'string';
column["hidden"] = false;
column["editable"] = true;
arr1.push(column);
column["name"] = "Age";
column["sorttype"] = 'int';
column["hidden"] = false;
column["editable"] = true;
arr1.push(column);
column["name"] = "Address";
column["sorttype"] = 'string';
column["hidden"] = false;
column["editable"] = true;
arr1.push(column);
Also have a jqgrid. Which use the columns exactly same as arr1
$("#grid").jqGrid({ //set your grid id
datatype: "local",
colNames: s,
colModel: [{
name: 'id',
index: 'id',
sorttype: 'int',
hidden:true ,
editable: false,
}, {
name: 'Name',
index: 'Name',
editable: false?,
}, {
name: 'Age',
index: 'Age',
editable: true,
}, {
name : 'Address',index :'Address'
sortable:true,
editable:true,
},
});
I want to replace the colModel from Jqgrid by arr1. Is it possible please help
Upvotes: 2
Views: 884
Reputation: 49
I add column["index"] and push to arr1 then replace the code by $("#grid").jqGrid({ //set your grid id datatype: "local", colNames: s, colModel: arr1 });
It is worked
Upvotes: 1
Reputation: 556
Yes, you just have to replace the colModel array with arr1
$("#grid").jqGrid({ //set your grid id
datatype: "local",
colNames: s,
colModel: arr1
});
Upvotes: 1