【发布时间】:2010-01-11 07:25:58
【问题描述】:
在第一次使用 jqGrid 的 ASP.NET MVC 应用程序中。
我有一个菜单,我从母版页的菜单中调用“员工”,如下所示:
<script language="javascript" type="text/javascript">
$(document).ready(function() {
$(".mnuEmployee").click(function() {
$.post("/Employee/Index", null, function(data) {
$("#text").html(data);
});
});
});
</script>
在控制器中,我有这个:
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Index()
{
EmployeeModel model = new EmployeeModel();
model.List = _employeeService.List();
model.Languages = _languageService.List();
return View("Index", model);
}
在视图(Index.ascx)中,我有这个:
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery("#sandgrid").jqGrid({
url: '/Employee/MyGridData/',
datatype: 'json',
mtype: 'GET',
height: 255,
width: 600,
colNames: ['Index', 'Name', 'Code'],
colModel: [
{ name: 'item_id', index: 'item_id', width: 65 },
{ name: 'item', index: 'item', width: 150 },
{ name: 'item_cd', index: 'item_cd', width: 100}],
pager: jQuery('#sandgridp'),
rowNum: 10,
rowList: [5, 10, 20, 50],
sortname: 'item_id',
sortorder: "desc",
viewrecords: true,
caption: 'Liste des employés'
});
});
</script>
<table id="sandgrid" cellpadding="0" cellspacing="0"></table>
<div id="sandgridp" style="text-align:center;"></div>
问题出在最后一部分(我认为),我的模型中有所有数据,我想在 jqGrid 中显示员工列表,并在经典文本框、textarea、...如何使用“model.List”(IList)在网格中显示?
谢谢,
【问题讨论】:
标签: asp.net-mvc json jqgrid