Creating JQGrid colModel from a javascript string variable
I am facing an issue while making a common grid control.
When I put
colModel:[ {name:"ID", index: "ID", width: 400, align: "Left"},{name:"Description", index: "Description", width: 400, align: "Left"}], It works.
When I am trying to replace the ColModel by a string variable I am not getting right display. colModel:[ColDisplay],
The problem is the following. When we put a string variable it comes like the following (with starting ending ‘) ‘{name:"ID", index: "ID", width: 400, align: "Left"},{name:"Description", index: "Description", width: 400, align: "Left"}’
If you put colModel:[ ‘{name:"ID", index: "ID", width: 400, align: "Left开发者_Go百科"},{name:"Description", index: "Description", width: 400, align: "Left"}’],
It is not able to understand the Columns.
Any solutions for this.
- Try eval("([" + ColModel + "])")
- Get FireBug
The []
indicate that its is an array.
Try this
var ColModel = [{name:"ID", index: "ID", width: 400, align: "Left"},{name:"Description", index: "Description", width: 400, align: "Left"}]
$("#gridid").jqGrid({
~
colModel:ColModel
~});
精彩评论