【问题标题】:jgGrid loadComplete callback event fires twicejgGrid loadComplete 回调事件触发两次
【发布时间】:2011-04-06 09:01:44
【问题描述】:

我在使用 jqGrid 时遇到问题,更具体地说是 loadComplete 回调事件。 当我第一次加载网格时, loadComplete 触发并且内部的功能按预期工作。但是如果我关闭它并再次打开,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");
        }

    });
}

【问题讨论】:

    标签: jquery asp.net asp.net-mvc


    【解决方案1】:

    你不会把这个当成 POST

    type: 'POST',
    

    你的行动只接受这样的

    [AcceptVerbs(HttpVerbs.Post)]
    

    你能看到这两个调用的确切触发了吗?

    【讨论】:

      猜你喜欢
      • 2011-05-26
      • 2014-04-07
      • 1970-01-01
      • 1970-01-01
      • 2013-03-28
      • 2013-09-12
      • 1970-01-01
      相关资源
      最近更新 更多