在首次使用jqGrid的ASP.NET MVC應用程序中。在jqGrid中顯示我的數據
我有一個菜單,我叫母版頁的「員工」,從菜單中是這樣的:
<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);
}
在View( 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)在網格中顯示?
謝謝,
顯示列表。在這個頁面上,不僅有jqGrid,還有其他一些控件,比如下拉菜單,textarea,... – 2010-01-11 12:04:14