Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery Grid showing no any items, despite controller action returning correct json data
    primarykey
    data
    text
    <p>Here's my client-side code:</p> <pre><code>$("#grid").jqGrid({ url: "/Entry/EntryListingByBreed/", datatype: "json", mtype: "POST", postData: { showId: showId, breedId: breedId }, colNames: ["Class", "NZKC Reg", "Registered name", "Date of birth", "Entered"], colModel: [ { name: "ClassNumber", sortable: false, width: 50 }, { name: "NZKCRegistration", sortable: false, width: 100 }, { name: "RegisteredName", sortable: false, width: 200 }, { name: "DateOfBirth", sortable: false, width: 200 }, { name: "Entered", sortable: false, width: 200 } ], pager: jQuery("#pager"), rowNum: 20, rowList: [10, 20, 40], altRows: true, altclass: "gridAltRow", viewrecords: true, caption: "Entries for " + breedName }); </code></pre> <p>and here is my server-side code:</p> <pre><code> [RequiresAuthentication] [HttpPost] public ActionResult EntryListingByBreed(int showId, int breedId, string sidx, string sord, int page, int rows) { using (var dataContext = new NZDogShowsEntities()) { int pageIndex = page - 1; int pageSize = rows; var entries = from se in dataContext.ShowEntries where se.ShowID == showId &amp;&amp; se.Entry.BreedID == breedId select se; int totalRecords = entries.Count(); int totalPages = (int)Math.Ceiling((float)totalRecords / (float)pageSize); var showEntries = (from se in dataContext.ShowEntries.AsEntryListingAggregate().AsEnumerable() where se.ShowID == showId &amp;&amp; se.Entry.BreedID == breedId select new { ID = se.ID, ClassNumber = se.Class.Number.ToString(), NZKCRegistration = se.Entry.NZKCRegNumber, RegisteredName = se.Entry.RegisteredName, DateOfBirth = se.Entry.DateOfBirth.GetValueOrDefault().ToLongDateString(), Entered = se.Entry.DateOfBirth.GetValueOrDefault().ToLongDateString() }).ToList(); var jsonData = new { total = totalPages, page = page, records = totalRecords, rows = ( from entry in showEntries select new { i = entry.ID, cell = new string[]{ entry.ClassNumber, entry.NZKCRegistration, entry.RegisteredName, entry.DateOfBirth, entry.Entered } }).ToArray() }; var viewData = Json(jsonData); return viewData; } } } </code></pre> <p>My server-side code looks a bit more verbose than necessary but it was good while I'm troubleshooting. The <code>viewData</code> variable is showing all the right data, number of rows, page number, etc. etc.</p> <p>The grid is formatted, ie. showing all the chrome surround, etc. However, no data is shown. Even the "Page x of y" is not correct. It's showing "Page 0 of" and the <code>&lt;span&gt;</code> where total number of records should show is blank. I'm at a lost here - probably missing something terribly obvious, especially since I'm a newbie to all this.</p> <p>Any help/pointers (pun-intended) would be greatly appreciated.</p> <p>Thanks.</p> <p>EDIT: Ok, the above server-side code has been fixed and now produces JSON string. It appears to be correctly formatted. I won't update the above code but will provide the JSON string below. It parses correctly but still Firebug reports "invalid label". The grid is not being populated either! Here's the string - can't for the life of me spot the problem:</p> <pre><code>{"total":2,"page":1,"records":25,"rows":[{"id":2,"cell":["2a","1234567","Test Dog","Monday, 1 January 0001","Monday, 1 January 0001"]},{"id":3,"cell":["4a","abcdef","Test Dog 2","Monday, 1 January 0001","Monday, 1 January 0001"]},{"id":4,"cell":["5a","abc123","Test Dog 3","Monday, 1 January 0001","Monday, 1 January 0001"]},{"id":5,"cell":["6a","asdf890","Test Dog X","Monday, 1 January 0001","Monday, 1 January 0001"]},{"id":6,"cell":["6","qwerty","Test Dog Y","Monday, 1 January 0001","Monday, 1 January 0001"]},{"id":7,"cell":["1","fw3asd","Test Dog 4","Monday, 1 January 0001","Monday, 1 January 0001"]},{"id":8,"cell":["10","asdfa","Test Dog 5","Monday, 1 January 0001","Monday, 1 January 0001"]},{"id":9,"cell":["11a","houh2","Test Dog 6","Monday, 1 January 0001","Monday, 1 January 0001"]},{"id":11,"cell":["8","xxxx","Test X","Monday, 1 January 0001","Monday, 1 January 0001"]},{"id":12,"cell":["8","zzzz","Test Z","Monday, 1 January 0001","Monday, 1 January 0001"]},{"id":13,"cell":["1","qqqq","Test Q","Monday, 1 January 0001","Monday, 1 January 0001"]},{"id":14,"cell":["8a","tttt","Test T","Monday, 1 January 0001","Monday, 1 January 0001"]},{"id":15,"cell":["8a","rrrr","Test R","Monday, 1 January 0001","Monday, 1 January 0001"]},{"id":16,"cell":["7","aaaa","Test A","Monday, 1 January 0001","Monday, 1 January 0001"]},{"id":17,"cell":["1","11223344","Test Entry","Monday, 1 January 0001","Monday, 1 January 0001"]},{"id":18,"cell":["1","66778899","asdfa","Monday, 1 January 0001","Monday, 1 January 0001"]},{"id":19,"cell":["1","13o24bo","qwlen;oq","Monday, 1 January 0001","Monday, 1 January 0001"]},{"id":20,"cell":["1","oubiou","asdfa","Monday, 1 January 0001","Monday, 1 January 0001"]},{"id":21,"cell":["1","o2no3","hohohop","Monday, 1 January 0001","Monday, 1 January 0001"]},{"id":22,"cell":["1","o48t2","Test 09808","Monday, 1 January 0001","Monday, 1 January 0001"]}]} </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload