0

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 Answers1

1

change your colModel to something like

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

    ]
Mobin Skariya
  • 392
  • 3
  • 12
  • Will you be able to help me with this ?? http://stackoverflow.com/questions/23659040/how-to-display-nested-json-object-in-jqgrid @MobinSkariya – Gotham's Reckoning May 14 '14 at 17:16