Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Found your post while I was trying to do this for my project. I got it working. For anyone who needs it in the future, jqGrid won't work out of the box with JSON and ASP.NET. You need to make a couple of small modifications to grid.base.js. Around line 829, replace the json case section with the following:</p> <pre><code>case "json": gdata = JSON.stringify(gdata); //ASP.NET expects JSON as a string $.ajax({ url: ts.p.url, type: ts.p.mtype, dataType: "json", contentType: "application/json; charset=utf-8", //required by ASP.NET data: gdata, complete: function(JSON, st) { if (st == "success") { addJSONData(cleanUp(JSON.responseText), ts.grid.bDiv); if (loadComplete) { loadComplete(); } } }, error: function(xhr, st, err) { if (loadError) { loadError(xhr, st, err); } endReq(); }, beforeSend: function(xhr) { if (loadBeforeSend) { loadBeforeSend(xhr); } } }); if (ts.p.loadonce || ts.p.treeGrid) { ts.p.datatype = "local"; } break; </code></pre> <p>Then add the following function:</p> <pre><code>function cleanUp(responseText) { var myObject = JSON.parse(responseText); //more secure than eval return myObject.d; //ASP.NET special } </code></pre> <p>You will also need to include the <a href="https://github.com/douglascrockford/JSON-js/blob/master/json2.js" rel="nofollow noreferrer">JSON parser and stringifier</a>. Along with working with ASP.NET, this revised code is also <a href="http://www.json.org/js.html" rel="nofollow noreferrer">more secure</a> because the eval statement is gone.</p> <p><strong>EDIT:</strong> I should have also noted that you might have to make similar edits to grid.celledit.js, grid.formedit.js, grid.inlinedit.js, and grid.subgrid.js.</p>
 

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