All I am just trying to figure this out with a very simple set of 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
<div class="sfcode">{"d":"name: Jeff V title: Programmer"}<br /><br />I want to load the grid using this JSON data.<br /><br />I have tried many different ways and examples to load this <br />into the grid but I have had 0 luck.<br />Here is my code:<br /><pre><br /><p>jQuery(document).ready(function () {</p><br /> <p>jQuery("#list").jqGrid({</p><br /> <p>datatype: processrequest,</p><br /> <p>mtype: 'POST',</p><br /> <p>colNames: ['Name', 'Title'],</p><br /> <p>colModel: [</p><br /> <p>{ name: 'name', index: 'name', width: 55 },</p><br /> <p>{ name: 'title', index: 'title', width: 90 }</p><br /> <p>],</p><br /> <p>pager: jQuery('#pager'),</p><br /> <p>rowNum: 10,</p><br /> <p>rowList: [10, 20, 30],</p><br /> <p>sortname: 'id',</p><br /> <p>sortorder: "desc",</p><br /> <p>viewrecords: true,</p><br /> <p>imgpath: 'themes/basic/images',</p><br /> <p>caption: 'My first grid'</p><br /> <p>});</p><br /> <p>});</p><br /> <br /><br /> <br /><br /> <p>function processrequest(postdata) {</p><br /> <p>$(".loading").show();</p><br /> <p>$.ajax({</p><br /> <p>type: "POST",</p><br /> <p>data: "{}",</p><br /> <p>dataType: "local",</p><br /> <p>url: "../webServices/myTestWS.asmx/testMethod",</p><br /> <p>contentType: "application/json; charset-utf-8",</p><br /> <p>complete: function (jsondata, stat) {</p><br /> <p>if (stat == "success") {</p><br /> <p>var thegrid = jQuery("#list")[0];</p><br /> <p>thegrid.addJSONData(eval("(" + jsondata.responseText + ").d"));</p><br /> <p>$(".loading").hide();</p><br /> <p>} else {</p><br /> <p>$(".loading").hide();</p><br /> <p>alert("Error with AJAX callback");</p><br /> <p>}</p><br /> <p>}</p><br /> <p>});</p><br /> <p>}</p><br /><br />Any help is appreciated! Thanks |
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top