Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_Related Related Topics sp_TopicIcon
Cannot get JQGrid working with JSON data
06/05/2012
21:45
Avatar
zippy
Member
Members
Forum Posts: 3
Member Since:
06/05/2012
sp_UserOfflineSmall Offline

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.

07/05/2012
02:45
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

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

Best regards
Oleg 

07/05/2012
05:20
Avatar
zippy
Member
Members
Forum Posts: 3
Member Since:
06/05/2012
sp_UserOfflineSmall Offline

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

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
47 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information