我正在尝试使用来自我的 [HttPost] 控制器方法的数据填充 jqgrid。
我的控制器看起来像这样
Public ActionResult Index()
{
SearchModel sm = new SearchModel();
// gets specific data from sm here
return View(sm);
}
[HttpPost]
Public ActionResult Index(SearchModel sm)
{
// does some stuff with the entered data from the form to return search results
// not sure what exactly to do here....
}
我的表格如下所示:
@model SearchModel
@{
//layout stuff and other script links are here
}
{Html.EnableClientValidation();}
@using (Html.BeginForm("Index", "Page",
FormMethod.Post, new { id = "search-form" }))
{
//I have the form and post data here
}
@if (Model.SearchRecords != null)
{
Html.RenderPartial("SearchRecordsPartial");
}
我的 jqgrid 所在的部分如下所示:
@model SearchModel
<div>
<table id="list" class="scroll" cellpadding="0" cellspacing="0"></table>
<div id="pager" class="scroll" style="text-align:center;"></div>
</div>
jQuery:
$(function () {
$("#list").jqGrid({
url: '/Page/Index/',
datatype: 'json',
mtype: 'GET',
colNames: ['Id', 'Votes', 'Title'],
colModel: [
{ name: 'Id', index: 'Id', width: 40, align: 'left' },
{ name: 'Votes', index: 'Votes', width: 40, align: 'left' },
{ name: 'Title', index: 'Title', width: 400, align: 'left'}],
pager: jQuery('#pager'),
rowNum: 10,
rowList: [5, 10, 20, 50],
sortname: 'Id',
sortorder: "desc",
viewrecords: true,
imgpath: '/content/themes/ui-lightness/images',
caption: 'Appeal Case Records'
});
});
任何有关如何执行此操作的帮助或链接都会很棒。我已经尝试在线搜索帮助,并且有很多不同的文章,但我似乎找不到使用 asp.net mvc 从表单数据填充 jqgrid 的文章。
谢谢,