I\'m sure this is something simple that I\'m missing, but I just can\'t seem to find it. I have a simple jqGrid specified here:
$(\'#mainGrid\').jqGrid({
According to the docs here, the expected json format is:
{
"total": "xxx",
"page": "yyy",
"records": "zzz",
"rows" : [
{"id" :"1", "cell" :["cell11", "cell12", "cell13"]},
{"id" :"2", "cell":["cell21", "cell22", "cell23"]},
...
]
}
Therefore you web service should be returning this:
{
"total": "4",
"page": "1",
"records": "4",
"rows" : [
{
"id": "4d4b8249-b5f9-4da6-aba2-bf3af588d560",
"name": "Pathway 1"
},
{
"id": "230184e6-44cc-4274-97fd-b455440cd9c0",
"name": "Pathway 2"
},
{
"id": "7f938218-b963-495f-9646-f3cfb1e63ea1",
"name": "Pathway 3"
},
{
"id": "2b17f23e-5500-4b01-ac1c-df2de90dc511",
"name": "Pathway 4"
}
]
}
At the moment you only have the rows array.
You could implement your own function to read the json, but i've never done this, see the "jsonReader as Function" section of the link above.
Edit:
I was wrong initially, either you should set the repeatitems flag to false:
jsonReader : {
repeatitems: false
},
and use the json above (i think!) or return data like this:
{
"total": "4",
"page": "1",
"records": "4",
"rows" : [
{
"id": "4d4b8249-b5f9-4da6-aba2-bf3af588d560",
"cells" : ["Pathway 1"]
},
{
"id": "230184e6-44cc-4274-97fd-b455440cd9c0",
"cells" : ["Pathway 2"]
},
{
"id": "7f938218-b963-495f-9646-f3cfb1e63ea1",
"cells" : ["Pathway 3"]
},
{
"id": "2b17f23e-5500-4b01-ac1c-df2de90dc511",
"cells" : ["Pathway 4"]
}
]
}
I've always done the latter, but i think the former is probably better!