dsjswclzh40259075 2014-02-24 21:17
浏览 32
已采纳

使用这种特殊格式来创建JQ Grid的Json

I'm new to Jquery &Json and i'm trying out Jqgrid I have a php page returning a particular format of json as given below

[{"properties":{"Name":"x","age":23,"loc":"venice"},
"Id":"422",
"Type":"bling"}]

I need some help to add this data into the grid None of the examples I see matches this format of Json

   $("#list").jqGrid({
        url: "test.php",
        datatype: "json",
        mtype: "GET",
        colNames: ["name", "age", "Loc"],
        colModel: [
            { name: "name", width: 55 },
            { name: "age", width: 90 },
            { name: "loc", width: 80, align: "right" }

        ],
        pager: "#pager",
        rowNum: 10,
        rowList: [10, 20, 30],
        sortname: "name",
        sortorder: "desc",
        viewrecords: true,
        gridview: true,

        autoencode: true,

        caption: "test",
         jsonReader : {
        repeatitems: true,
        cell: "cell",
        id:"id",
        userdata: "userdata",
        root: "properties",
        page: "page",
        total: "total",
        records: "records"
       }  
    }); 

With my minimum understanding I guess its about json reader Help would be appreciated

THANKS IN advance

  • 写回答

1条回答 默认 最新

  • dqqfuth6736 2014-02-25 06:38
    关注

    change your colModel to something like

    colModel: [
            { name: "properties.Name", width: 55 },
            { name: "properties.age", width: 90 },
            { name: "properties.loc", width: 80, align: "right" }
    
        ]
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 R语言卸载之后无法重装,显示电脑存在下载某些较大二进制文件行为,怎么办
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?
  • ¥15 关于#vue.js#的问题:修改用户信息功能图片无法回显,数据库中只存了一张图片(相关搜索:字符串)
  • ¥15 texstudio的问题,
  • ¥15 spaceclaim模型变灰色
  • ¥15 求一份华为esight平台V300R009C00SPC200这个型号的api接口文档
  • ¥15 字符串比较代码的漏洞
  • ¥15 欧拉系统opt目录空间使用100%
  • ¥15 ul做导航栏格式不对怎么改?