如何从jqgrid调用控制器方法。 [英] How to call controller method from jqgrid.
问题描述
我添加了所有必要的Jquery& JqGrid脚本和CSS。
我正在使用MVC5。
i得到Uncaught TypeError:无法读取属性'msie'未定义错误。
所以我添加了jquery-migrate-1.2.1脚本。在Jquery之后。
- 警告msg JQMIGRATE:jQuery.browser已被弃用。
我尝试了什么:
I have added all necesary Jquery & JqGrid scripts and css.
I am using MVC5.
i got "Uncaught TypeError: Cannot read property 'msie' of undefined" error.
So I have added jquery-migrate-1.2.1 script. after Jquery.
--warning msg JQMIGRATE: jQuery.browser is deprecated.
What I have tried:
$(document).ready(function () {
debugger;
$('.Importtbl').jqGrid({
datatype: 'Json',
mtype: 'GET',
url: '@Url.Action("ImportData", "ReportablePayments")',
colNames: ['PaymentDate', 'PayeeName', 'SrcDocType', 'Amount', 'Check Number', 'Object Code'],
colModel: [
{ name: 'PaymentDate', index: 'PaymentDate', width: 20 },
{ name: 'PayeeName', index: 'PayeeName', width: 50 },
{ name: 'SrcDocType', index: 'SrcDocType', width: 20 },
{ name: 'Amount', index: 'Amount', width: 15 },
{ name: 'CheckNumber', index: 'CheckNumber', width: 20 },
{ name: 'ObjectCode', index: 'ObjectCode', width: 10 }
],
pager: '#pager',
caption: 'Import Raw DATA',
viewrecords: true,
rowNum:10
})
});
---- Controller.cs
public ActionResult ImportData(int rows,string sidx,string sord,int page)
{
返回Json(null,JsonRequestBehavior.AllowGet);
}
----Controller.cs
public ActionResult ImportData(int rows,string sidx,string sord,int page)
{
return Json(null,JsonRequestBehavior.AllowGet);
}
推荐答案
( document )。ready( function (){
debugger ;
(document).ready(function () { debugger;
(' 。Importtbl')。 jqGrid({
datatype:' Json',
mtype:' GET',
url:' @ Url.Action(ImportData,ReportablePayments)',
colNames:[' PaymentDate',' PayeeName',' SrcDocType',< span class =code-string>' 金额',' Check Number',' Object Code'],
colModel:[
{name:' PaymentDate',index: PaymentDate',宽度: 20 },
{name:' P ayeeName',index:' PayeeName',width: 50 },
{名称:' SrcDocType',index :' SrcDocType',width: 20 },
{name:' Amount',index:' 金额',宽度: 15 },
{name :' CheckNumber',index:' CheckNumber',width: 20 },
{name:' ObjectCode',索引:' ObjectCode',width: 10 }
],
pager:' #pager',
标题:' 导入原始数据',
viewrecords: true ,
rowNum: 10
})
});
('.Importtbl').jqGrid({ datatype: 'Json', mtype: 'GET', url: '@Url.Action("ImportData", "ReportablePayments")', colNames: ['PaymentDate', 'PayeeName', 'SrcDocType', 'Amount', 'Check Number', 'Object Code'], colModel: [ { name: 'PaymentDate', index: 'PaymentDate', width: 20 }, { name: 'PayeeName', index: 'PayeeName', width: 50 }, { name: 'SrcDocType', index: 'SrcDocType', width: 20 }, { name: 'Amount', index: 'Amount', width: 15 }, { name: 'CheckNumber', index: 'CheckNumber', width: 20 }, { name: 'ObjectCode', index: 'ObjectCode', width: 10 } ], pager: '#pager', caption: 'Import Raw DATA', viewrecords: true, rowNum:10 }) });
---- Controller.cs
public ActionResult ImportData(int rows,string sidx,string sord,int page)
{
返回Json(null,JsonRequestBehavior.AllowGet);
}
----Controller.cs
public ActionResult ImportData(int rows,string sidx,string sord,int page)
{
return Json(null,JsonRequestBehavior.AllowGet);
}
这篇关于如何从jqgrid调用控制器方法。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!