Forum
21:45
06/05/2012
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
10/08/2009
I answered you here before. You should use jsonReader instead of jsonreader to solve the problem.
Best regards
Oleg
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.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66