Forum

July 10th, 2011
You must be logged in to post Login Register

Search Forums:


 






Cannot get JQGrid working with JSON data

UserPost

21:45
06/05/2012


zippy

Member

posts 3

Post edited 21:47 – 06/05/2012 by zippy
Post edited 21:48 – 06/05/2012 by zippy
Post edited 21:50 – 06/05/2012 by zippy
Post edited 21:53 – 06/05/2012 by zippy
Post edited 21:53 – 06/05/2012 by zippy


Hello. I am new to JQGrid and have been trying to get it working with some JSON data, but it's not going well. I wonder if anyone would be kind enough to help me out.

Here's my JSON data:

{ "total":"1", "page":"1", "userdata":{ }, "records":"2", "rows":[ { "DateOfBirth":"11/04/2012 12:00:00 AM", "DisambiguationNote":"Boring guy", "FirstName":"Joe", "LastName":"Bloggs", "MiddleName":"Binkie", "PersonId":"1" }, { "DateOfBirth":"01/01/2001 12:00:00 AM", "DisambiguationNote":"someone else", "FirstName":"Edna", "LastName":"Edwards", "MiddleName":"Edith", "PersonId":"8" } ] }

And here's my grid code:

$(function () { $("#persongrid").jqGrid({ url: '/Person/List', datatype: 'json', mtype: 'GET', jsonreader: { root: "rows", page: "page", total: "total", records: "records", repeatitems: false, id: "5" , cell: "" , userdata: "userdata" }, colModel: [ { name: 'DateOfBirth', index: 'DateOfBirth',sorttype:'date' }, { name: 'DisambiguationNote', index: 'DisambiguationNote' }, { name: 'FirstName', index: 'FirstName' }, { name: 'LastName', index: 'LastName' }, { name: 'MiddleName', index: 'MiddleName' }, { name: 'PersonId', index: 'PersonId',sorttype:'int' } ], pager: '#persongridpager', rowNum: 10, rowList: [10, 20, 30], viewrecords: true, gridview: true, caption: 'People' }); });

What I get is a grid that has the column headings but no contents. It just displays "Loading…" forever.

After a bit of investigation I can see that it makes multiple calls to the getAccessor method and on the last call the first parameter to the method (obj) is undefined. That seems to be what's causing the grid to stop rendering, but why?

I can see that the JSON data is being retrieved as above from the AJAX request, and I have been through the JSON data instructions for JQGrid quite carefully but can't see what I'm doing wrong. Can anyone help? Thank you.

02:45
07/05/2012


OlegK

Germany

Member

posts 1167

Post edited 02:45 – 07/05/2012 by OlegK


I answered you here before. You should use jsonReader instead of jsonreader to solve the problem.

Best regards
Oleg 

05:20
07/05/2012


zippy

Member

posts 3

Oleg, thank you again. That was the problem and I had stared at it for so long without spotting that.


About the jQuery Grid Plugin – jqGrid forum

Most Users Ever Online:

157


Currently Online:

JQGridUserforMVC

anand_matta

97 Guests

Forum Stats:

Groups: 1

Forums: 7

Topics: 9659

Posts: 28945

Membership:

There are 10353 Members

There have been 448 Guests

There is 1 Admin

There are 2 Moderators

Top Posters:

OlegK – 1167

markw65 – 179

kobruleht – 144

phicarre – 126

YamilBracho – 124

Renso – 118

Administrators: admin (56 Posts)

Moderators: tony (7043 Posts), Rumen[Trirand] (81 Posts)




Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information