在ASP.NET MVC 3.0应用程序中,我使用jqGrid。我使用下面的代码。我看到网格,但没有数据。我通过了“GridData”操作,列表内容是一个元素,但网格中没有任何内容。jqGrid没有数据显示在网格中
C#:
public ActionResult GridData()
{
List<Customer> list = new List<Customer>();
list.Add(new Customer() { Code = "AAA", FirstName = "BBB", LastName = "CCC" });
return Json(list);
}
HTML:
<table id="jqgProducts" cellpadding="0" cellspacing="0"></table>
<div id="jqgpProducts" style="text-align:center;"></div>
<script type="text/javascript">
$(document).ready(function() {
$('#jqgProducts').jqGrid({
//url from wich data should be requested
url: '/Customer/GridData/',
//type of data
datatype: 'json',
//url access method type
mtype: 'GET',
//columns names
colNames: ['Id', 'LastName','FirstName', 'Code'],
//columns model
colModel: [
{ name: 'Id', index: 'Id', align: 'left' },
{ name: 'LastName', index: 'LastName', align: 'left' },
{ name: 'FirstName', index: 'FirstName', align: 'left' },
{ name: 'Code', index: 'Code', align: 'left' }
],
//pager for grid
pager: $('#jqgpProducts'),
//number of rows per page
rowNum: 10,
//initial sorting column
sortname: 'Id',
//initial sorting direction
sortorder: 'asc',
//we want to display total records count
viewrecords: true
});
});
</script>
我试过你的代码一些结果...网格中没有数据 –
你应该使用调试器,然后获得更多关于你的问题的信息 – Zruty
你认为我不使用调试器? :)在返回的调试点中,列表有1个元素。我无法告诉你更多。 –