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:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
<div class="sfcode">{<br /> "total":"1",<br /> "page":"1",<br /> "userdata":{<br /> <br /> },<br /> "records":"2",<br /> "rows":[<br /> {<br /> "DateOfBirth":"11/04/2012 12:00:00 AM",<br /> "DisambiguationNote":"Boring guy",<br /> "FirstName":"Joe",<br /> "LastName":"Bloggs",<br /> "MiddleName":"Binkie",<br /> "PersonId":"1"<br /> },<br /> {<br /> "DateOfBirth":"01/01/2001 12:00:00 AM",<br /> "DisambiguationNote":"someone else",<br /> "FirstName":"Edna",<br /> "LastName":"Edwards",<br /> "MiddleName":"Edith",<br /> "PersonId":"8"<br /> }<br /> ]<br /> }<br /> </div> |
And here's my grid code:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
<div class="sfcode">$(function () {<br /> $("#persongrid").jqGrid({<br /> url: '/Person/List',<br /> datatype: 'json',<br /> mtype: 'GET',<br /> jsonreader: {<br /> root: "rows",<br /> page: "page",<br /> total: "total",<br /> records: "records",<br /> repeatitems: false,<br /> id: "5" ,<br /> cell: "" ,<br /> userdata: "userdata"<br /> },<br /> colModel: [<br /> { name: 'DateOfBirth', index: 'DateOfBirth',sorttype:'date' },<br /> { name: 'DisambiguationNote', index: 'DisambiguationNote' },<br /> { name: 'FirstName', index: 'FirstName' },<br /> { name: 'LastName', index: 'LastName' },<br /> { name: 'MiddleName', index: 'MiddleName' },<br /> { name: 'PersonId', index: 'PersonId',sorttype:'int' }<br /> ],<br /> pager: '#persongridpager',<br /> rowNum: 10,<br /> rowList: [10, 20, 30],<br /> viewrecords: true,<br /> gridview: true,<br /> caption: 'People'<br /> });<br /> });</div> |
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.
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top