저는 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'); });
내 첫 두 경고 화재 :
나는 여기에 내 headcontent 년대 URL.Content() 메소드 를 사용하여 모든 JQuery와 & 그리드 파일을 참조. 하지만 일단 jGrid 함수로 들어가면 세 번째 경고가 발생하지 않습니다. 컨트롤러의 함수에 중단 점을 넣었으므로 URL과 관련이있을 수 있다고 생각합니다. 결코 충돌하지 않습니다.
두 번째 문제는 주소 표시 줄에 /Bar.mvc/GridData를 입력하여 함수를 찾을 수 있는지 여부를 확인하는 것입니다. 파이어 폭스의 "파일 저장 ..."으로 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);
}