我有报告名称的动态按钮,每次用户单击按钮时,它都会显示适用于所有报告的搜索字段(开始日期,结束日期),所有报告都有不同的页面以自己的网格显示,现在如何传递参数并打开报表的相应页面并加载jqgrid。我一直将这个传递参数存入“OnlineSales”页面,然后加载网格。提前感谢您的帮助!
单击搜索按钮后,调用 OnlineSales 页面并传递参数然后在网格中显示数据的语法是什么。
$('#SearchButton').click(function () {
var _StartDate = $("#StartDate").val();
var _EndDate = $("#EndDate").val();
});
使用参数调用 OnlineSales 视图
@{
ViewBag.Title = "OnlineSales";
}
@*GRID*@
<div id="table" class="table">
<table id="List" class="scroll" cellpadding="0" cellspacing="0"></table>
<div id="Pager" class="scroll" style="text-align:center;"></div>
</div>
@*GRID*@
<script type="text/javascript">
jQuery(document).ready(function () {
jQuery("#List").jqGrid({
url: 'local',
postData: { start_date: '', end_date: ''},
datatype: "json",
mtype: 'GET',
colNames: [
'First Name',
'Middle Name',
'Last Name',
'Email',
'Mobile Number'],
colModel: [
{ name: 'FirstName', index: 'FirstName', width: 200, align: 'left' },
{ name: 'MiddleName', index: 'MiddleName', width: 200, align: 'left' },
{ name: 'LastName', index: 'LastName', width: 150, align: 'left' },
{ name: 'Email', index: 'Email', width: 150, align: 'left' },
{ name: 'MobileNumber', index: 'MobileNumber', width: 80, align: 'left' }],
pager: jQuery('#Pager'),
rowNum: 10,
rowList: [5, 10, 20, 50, 100],
sortname: 'FirstName',
width: '1005',
sortorder: "asc",
sorttype: 'int',
viewrecords: true,
height: 'auto',
shrinkToFit: false,
cache: false,
caption: 'Online Sales'
});
jQuery("#List").jqGrid('navGrid', '#Pager', { edit: false, add: false, del: false, search: false, refresh: true });
});
</script>
我的控制器
public ActionResult OnlineSales(string sidx, string sord, int page, int rows, DateTime start_date, DateTime end_date)
{
_DashboardDataAccess = new DashboardDataAccess(0);
List<OnlineSales> _OnlineSales = _DashboardDataAccess.OnlineSales(start_date, end_date);
var result = _OnlineSales.AsQueryable().AsEnumerable<OnlineSales>();
int count = result.Count();
result = result.Skip((page - 1) * rows).Take(rows);
int pagecount = (count % rows) == 0 ? (count / rows) : (count / rows) + 1;
var ReportList = (from r in result
select new
{
cell = new string[] {
r.FirstName,
r.MiddleName,
r.LastName,
r.Email,
r.MobileNumber
}
});
var jsonData = new
{
total = pagecount,
page = page,
records = count,
rows = ReportList.ToArray()
};
return Json(jsonData, JsonRequestBehavior.AllowGet);
}