开发者

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.


  1. Try eval("([" + ColModel + "])")
  2. 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
~});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜