私はAsp.Net MVCアプリケーションでjQueryのグリッド機能を実装しようとしています。私は今、XP上のすべてをテストしているので、mvc拡張機能を有効にしました(IIS 5を使用しているので)jQueryGridがASP.Net MVCでURLを呼び出さない
私は2つの問題に遭遇しました。
- jqueryグリッドが呼び出されていないようです。
jQuery(document).ready(function() { alert('loaded'); alert('starting jquery'); jQuery("#list").jqGrid ({ url: '/Bar.mvc/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: 400, 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' }); alert('jQuery done'); });
私の最初の2つの警告火災:
は、私はここに私のheadcontentだURL.Content()メソッド を使用して、すべてのjqueryの&グリッドファイルを参照します。しかし、それがjGrid関数に入ると、3番目のアラートは起動しません。私はコントローラの関数にブレークポイントを設定したので、URLに関連している可能性があると考えています。
私の2番目の問題は、アドレスバーに/Bar.mvc/GridDataを入れて、機能を見つけることさえできるかどうかを確認することです。Firefoxの「ファイルを保存...」でjsonタイプのファイルをダウンロードするように促します。 "ダイアログ。第三のアラートが起動しない場合は、jqGridへの呼び出しが死にかけている
public ActionResult GridData(string sidx, string sord, int? page, int? rows)
{
int totalPages = 1; // we'll implement later
int? pageSize = rows;
int totalRecords = 3; // implement later
var jsonData = new
{
total = totalPages,
page = page,
records = totalRecords,
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);
}