mvc 프로젝트에 jquery 표를 설치하고 jquery UI에 연결했습니다. 초기로드는 정상이며 컨트롤러에서 작업 호출을보고 결과가 예상대로 표시됩니다. 머리글 중 하나를 클릭하여 정렬하면 아무 것도 나타나지 않고 컨트롤러에서 작업이 호출되지 않습니다. 나는 방화범에 아무런 오류가 없다.jqGrid 이벤트가 실행되지 않음
내가 뭔가를 잃어버린거야?
public ActionResult GetRateTypes(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, JsonRequestBehavior.AllowGet);
}
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery("#list").jqGrid({
url: '/Configuration/GetRateTypes',
datatype: 'json',
mtype: 'GET',
colNames: ['Code', 'Name', 'Rate'],
colModel: [
{ name: 'Code', index: 'Code', width: 40, align: 'left' },
{ name: 'Name', index: 'Name', width: 40, align: 'left' },
{ name: 'Rate', index: 'Rate', width: 400, align: 'left'}],
pager: jQuery('#pager'),
rowNum: 1,
rowList: [5, 10, 20, 50],
sortname: 'Code',
sortorder: "desc",
viewrecords: true,
imgpath: '/css/blitzer/',
caption: 'Interest Rate Types'
});
});
</script>
답장을 보내 주셔서 감사합니다. 나는 그 행동이 어떤 종류의 정렬도하지 않고 그것을 단순하게 남겨 두었다는 것을 안다. 내가 겪고있는 문제는 정렬 이벤트가 액션으로 다시 시작되지 않는다는 것입니다. 열 머리글을 클릭하면 이벤트가 시작되지 않으므로 컨트롤러의 작업이 호출되지 않습니다. – Chev
@Chev : 열 머리글을 클릭하면 그리드가 다시로드되고 다른'sidx' 및'sord' 값으로'GetRateTypes'가 호출됩니다. – Oleg
@Chev : jqGrid에서도 사용되는 몇 가지 옵션을 "간단하게"제거했을 것입니까? 예를 들어'loadonce : true'를 사용하면 첫 번째 선행 다음에'datatype : 'json''이'datatype :'local''로 변경되고 정렬 및 페이징과 같은 작업은 사용자의 호출없이 로컬에서 수행됩니다 서버 구성 요소. 실제로 사용하는 코드를 게시했는지 확인하십시오. 반대쪽에서는 모든 colModel 항목에서 제거 할 수있는'align : 'left'디폴트 설정과'imgpath' 매개 변수는 jqGrid에 의해 사용되지 않기 때문에 삭제되어야합니다. – Oleg