【问题标题】:Using this Particular format to Json in creating JQ Grid在创建 JQ Grid 时对 Json 使用这种特定格式
【发布时间】:2014-02-24 21:17:55
【问题描述】:

我是 Jquery &Json 的新手,我正在尝试 Jqgrid 我有一个返回特定格式的 json 的 php 页面,如下所示

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

我需要一些帮助才能将此数据添加到网格中 我看到的例子都不匹配这种格式的 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"
       }  
    }); 

根据我的最低理解,我猜它是关于 json reader 帮助将不胜感激

提前致谢

【问题讨论】:

    标签: php jquery json jqgrid


    【解决方案1】:

    将您的 colModel 更改为类似

    colModel: [
            { name: "properties.Name", width: 55 },
            { name: "properties.age", width: 90 },
            { name: "properties.loc", width: 80, align: "right" }
    
        ]
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-10-25
    • 1970-01-01
    • 1970-01-01
    • 2018-08-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多