Jqgridの実装中にパラメーターを渡し、getメソッドを呼び出すときに問題に直面しています。
私のアプリケーションの仕組みは、対応する Java スクリプト ファイルである .htm ファイルのセットを持っていることです。今、私は 1 つのタブで jqgrid を実装したいと考えています。必要な関数をすべて追加しましたが、コントローラーメソッド自体が親切に呼び出されません。
ここに私の.htmファイルがあります
<div id="report-tab">
<h2>My Grid Data</h2>
<table id="list" class="scroll" cellpadding="0" cellspacing="0"></table>
<div id="pager" class="scroll" style="text-align:center;"></div>
</div>
これが私のreport.jsファイルです。制御はinit関数まで来ますが、それは私のc#関数をトリガーしません。つまり、json メソッドです。
var ReportTab = function () {
return {
Init: function () {
//Control comes till here, but it wont go inside,
jQuery(document).ready(function() {
jQuery("#list").jqGrid({
Url: '/Home/GridData',
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: 200, align: 'left'}],
pager: jQuery('#pager'),
rowNum: 10,
rowList: [5, 10, 20, 50],
sortname: 'Id',
sortorder: "desc",
viewrecords: true,
imgpath: '/scripts/themes/coffee/images',
caption: 'My first grid'
});
});
}
}
} ();
これが私のコントローラー関数です
public ActionResult GridData(string sidx, string sord, int page, int rows)
{
_logger.LogMethodAndType();
var jsonData = new
{
total = 1, // we'll implement later
page = page,
records = 3, // implement later
rows = new[]{
new {id = 1, cell = new[] {"1", "-7", "Is this a good question?"}},
new {id = 2, cell = new[] {"2", "15", "Is this a blatant ripoff?"}},
new {id = 3, cell = new[] {"3", "23", "Why is the sky blue?"}}
}
};
return Json(jsonData, JsonRequestBehavior.AllowGet);
}
前もって感謝します。