0
다음은 jqgrid (v 4.6.0)를 설정 한 것입니다.jqgrid subgrid가 데이터를로드하지 않습니다 (서버에 Ajax 호출이 전송되지 않음)
$(function() {
var JQGridDefaults = {
caption: '',
rowList: [10, 50, 100],
datatype: 'json',
height: '100%',
viewrecords: true,
mtype: 'GET',
colNames: ['Item Control No', 'Item Short Description', 'ID'],
colModel: [
{
name: 'ItemCode', index: 'ItemCode', search: true, width: 230, cellattr: makeCellContentWrap, searchoptions: {
sopt: ['eq', 'ne', 'bw', 'bn', 'ew', 'en', 'cn', 'nc'],
},
searchrules: {required: true}
},
{
name: 'ItemShortDesc', index: 'ItemShortDesc', search: true, width: 300, cellattr: makeCellContentWrap, searchoptions: {
sopt: ['eq', 'ne', 'bw', 'bn', 'ew', 'en', 'cn', 'nc'],
},
searchrules: {required: true }
}
//Hidden Fields - Start
{ name: 'ItemID', hidden: true, key: true }
//HiddenFields End
],
pager: '#GridPager',
rowNum: 10,
sortname: 'ItemCode',
sortorder: 'asc',
url: '/Items/List',
jsonReader: {
root: "rows",
page: "page",
total: "total",
records: "records",
repeatitems: false,
userdata: "userdata",
subgrid: {
root: "rows",
repeatitems: false
}
},
//Sub Grid - Start
subGrid: true,
subGridBeforeExpand: function (pID, rowID) {
console.log("Before Expand");
var gridData = $(this).jqGrid('getRowData',rowID);
if (gridData.ItemCode == "") {
return false;
}
},
subGridUrl: '/Items/Details',
subGridModel: {
name: ['Revision', 'ItemCode'],
width: [50, 100],
align: ['center', 'center'],
mapping: ['Revision', 'ItemCode']
},
afterInsertRow: function (rowid, aData, rowelem) {
// Remove the subgrid plus button except for rows that have exceptions
if (aData.ItemCode == "") {
$('#' + rowid).children("td.sgcollapsed").unbind();
$('#' + rowid).children("td.sgcollapsed").html("");
}
}
//Sub Grid - END
};
var JQGridSearchDefaults = {
multipleSearch: true,
recreateFilter: true,
showQuery: true,
closeAfterSearch: true,
closeAfterReset: true,
searchOnEnter: true,
closeOnEscape:true,
width: 600
};
$('#Grid').jqGrid(JQGridDefaults).navGrid('#GridPager', { view: false, del: false, add: false, edit: false, refresh: true },
{},
{},
{},
JQGridSearchDefaults);
$('#Grid').jqGrid('setGridWidth', $('#Grid').parents('.main-content').width() - 2);
$(window).resize(function() {
clearTimeout(this.id);
this.id = setTimeout(function() {
$('#Grid').jqGrid('setGridWidth', $('#Grid').parents('.main-content').width() - 2);
}, 300);
});
});
하위 그리드 아이콘이 제대로 표시하지만이 확장 아이콘을 클릭하면 빈 행은 (어떤 헤더가 더 AJAX 호출이 전송되지 않습니다) 나타납니다
사람이 AJAX 호출이 이유에 대한 아이디어가 않습니다 안 그런가?
참고 : 또한 'subgridtype'매개 변수를 사용하고 Ajax 호출을하지 않은 서비스 호출을 정의하려고했습니다. 당신이 JSON을 subgridtype 시도에 대한
subgridtype: function (rowidparam) {
$.ajax({
url: '/Items/Details',
cache: false,
type: 'Get',
dataType: "json",
data: { id: rowidparam.ItemID }
}).done(function (data) {
$('#Grid')[0].subGridJson(data, rowidparam.id);
});
},
당신의 자바 스크립트에서 예외를 던지고 있는지 확인하기 위해 브라우저에서 자바 스크립트 디버거를 사용하여 (또는 확장의 하나) 시도 그리드가 작동하지 않을 수도 있습니다. 그게 종종 가져 오기로 돌아 가지 않을 때 가지고있는 문제입니다. – Andy
안녕하세요. 나는 그것을 시험해 보았다. 그러나 예외는 발생하지 않습니다. 내가 어떤 종류의 오류 (Exception)를 얻는다면, 나는 틀린 것에 대한 아이디어를 얻을 수있다. – InsI