I'm trying to use Jquery grid with asp.net, but its not working, it shows the grid with empty content, i'm not sure whats wrong with my code!! here is my HTML code:
<script type="text/javascript">
$(function () {
$("#list").jqGrid({
url: '/WebServices/Admin/WebMethods.ashx',
datatype: 'json',
mtype: 'POST',
colNames: ['ID', 'Name', 'Description'],
colModel: [
{ name: 'ID', index: 'ID', width: 55 },
{ name: 'NAME', index: 'NAME', width: 90 },
{ name: 'DESCRIPTION', index: 'DESCRIPTION', width: 80 }
],
jsonReader: {
repeatitems:false
},
pager: $('#pager'),
rowNum: 10,
rowList: [10, 20, 30],
sortname: 'ID',
sortorder: 'desc',
viewrecords: true,
caption: 'Lockups'
}).navGrid('#pager');
});
</script>
Followed by:
<form runat="server">
<div style="width:700px">
<table id="list" width="100%">
<tr>
<td />
</tr>
</table>
<div id="pager">
</div>
</div>
</form>
my C# code, im converting my list of objects to JSON :
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "application/json";
context.Response.Write(GetAllLookups());
}
public string GetAllLookups()
{
var lst = from lockup in LOCKUP_ITEMS.GetLockups()
select new {
ID = lockup.ID,
NAME = lockup.NAME,
DESCRIPTION = lockup.DESCRIPTION
};
return Newtonsoft.Json.JsonConvert.SerializeObject(
lst,
new JavaScriptDateTimeConverter());
}