3
jqGrid, 특히 loadComplete 콜백 이벤트를 사용하는 데 문제가 있습니다. 처음으로 그리드를로드하면 loadComplete가 실행되고 내부 함수가 예상대로 작동합니다. 하지만 닫고 다시 한 번 열면 loadComplete는 예상되는 동작이 아닌 두 번 발생합니다. 왜 그럴 수 있겠 어? 여기 jgGrid loadComplete 콜백 이벤트가 두 번 발생합니다.
는 할당하십시오이 버튼의 onclick 이벤트에 내 기능입니다 : 행동만을 받아들이는function stcoll_BindDataScholarship() {
var actionwithparams = '<%= Url.Action("LoadListFoundStudentsFromScholarshipBox", "ManageStudents", new {area="Admin", scholarshipId = "stcoll_scholarsipId", byName = "", byFirstorSecondName = "", searchStart = "", searchEnd = "", byYear = "", byGroupId = "", SelectCommunityIs = "_districtCommunityId_" })%>';
actionwithparams = actionwithparams.replace("stcoll_scholarsipId", $("#stcoll_scholarsipIdScholarship").val());
actionwithparams = actionwithparams.replace("_districtCommunityId_", $("[name=CommunityDDL]").val());
$("#stcoll_studentListScholarship").GridUnload();
jQuery("#stcoll_studentListScholarship").jqGrid({
url: actionwithparams,
editurl: '<%= Url.Action("EditGroup", "ManageStudents", new {area="Admin"})%>',
datatype: 'json',
mtype: 'GET',
colNames: ['',
'<%=Resources.ScholarshipSearch.StudentScholarshipBox_ascx.Text_FirstName%>',
'<%=Resources.ScholarshipSearch.StudentScholarshipBox_ascx.Text_LastName%>',
'<%=Resources.ScholarshipSearch.StudentScholarshipBox_ascx.Text_OnScholarshipList%>',
'<%=Resources.ScholarshipSearch.StudentScholarshipBox_ascx.Text_Year%>',
"Id"
],
colModel: [
{ name: 'Check', index: 'Check', editable: false, sortable: false, width: 30, align: "center" },
{ name: 'FirstName', index: 'FirstName', editable: false, width: 125, sortable: true },
{ name: 'LastName', index: 'LastName', editable: false, width: 125, sortable: true },
{ name: 'OnList', index: 'OnList', editable: false, width: 100, align: 'center', sortable: true },
{ name: 'Year', index: 'Year', editable: false, width: 50, sortable: true },
{ name: 'Id', index: 'Id', editable: false, width: 10, hidden: true }
],
pager: jQuery('#stcoll_pagered'),
onPaging: function (pgButton) {
if (pgButton == "records") {
$("#stcoll_studentListScholarship").setGridParam({ page: 1 }).trigger("reloadGrid");
}
},
rowNum: 10,
rowList: [2, 10, 20, 30],
viewrecords: true,
imgpath: '<%=ResolveUrl("~/themes/base/images")%>',
width: 550,
height: 250,
emptyrecords: '<%=Resources.ScholarshipSearch.StudentScholarshipBox_ascx.Text_NoRecords%>',
loadtext: '<%=Resources.ScholarshipSearch.StudentScholarshipBox_ascx.Text_Loading%>',
pgtext: '<%=Resources.Shared.SharedResources.Text_PageOf%>',
recordtext: '<%=Resources.Shared.SharedResources.Text_ViewOf%>',
rownumbers: false,
sortable: false,
beforeRequest: function() {
var p = $.browser.version.split(".");
if ($.browser.mozilla && p[0] == 1 && p[1] == 9 && p[2] == 0) $(".ui-pg-input").css("height", "15px");
if ($.browser.msie) {
if ($.browser.version == 7.0) $(".ui-pg-input").css("height", "17px");
else $(".ui-pg-input").css("height", "20px");
}
},
loadComplete: function() {InitStudentScholarshipGrid() },
multiselect: false,
gridComplete: function() {
$(".ui-jqgrid-view input[type='checkbox']").css("margin", "2px 0 0 0");
}
});
}