1

我收到错误消息:

Microsoft JScript 运行时错误:“prmGridDialog”未定义

双击 jQgrid 中的一行时。当我使用工具栏按钮时,对话框打开。其他一切工作正常。这是jQuery:

<script src="~/Scripts/jquery.jqGrid.min.js"></script>
<script src="~/Scripts/i18n/grid.locale-en.js"></script>
<script src="~/Scripts/json2.min.js"></script>
<script src="~/Scripts/jquery.jqGrid.src.js"></script>
<link href="~/Content/jquery.jqGrid/ui.jqgrid.css" rel="stylesheet" />

$(document).ready(function() {
    $.jgrid.nav.addtext = "Add";
    $.jgrid.nav.edittext = "Edit";
    $.jgrid.nav.deltext = "Delete";
    $.jgrid.edit.addCaption = "Add Item";
    $.jgrid.edit.editCaption = "Edit Item";
    $.jgrid.del.caption = "Delete Contact";
    $.jgrid.del.msg = "Delete selected item?";

    var updateDialog = {
        url: '/VisitorProducts/EditjQGridData'
        , closeAfterEdit: true
        , closeOnEscape: true
        , modal: true
        , width: "400"
    };

    var addDialog = {
        url: '/VisitorProducts/AddjQGridData'
        , closeAfterAdd: true
        , closeOnEscape: true
        , modal: true
        , width: "400"
    };

    var deleteDialog = {
        url: '/VisitorProducts/DeletejQGridData'
        , closeAfterEdit: true
        , closeOnEscape: true
        , modal: true
        , width: "400"
    };

    jQuery("#list2").jqGrid({
        url: '/VisitorProducts/jQgridData?visitorId=32'
        , datatype: "json"
        , colNames: ['RowId', 'VisitorId', 'Product Name']
        , colModel: [
            { name: 'RowId', index: 'RowId', width: 150, editable: false, edittype: 'text', key: true },
            { name: 'VisitorId', index: 'VisitorId', width: 150, editable: true, edittype: 'text' },
            { name: 'ProductName', index: 'ProductName', sortable: true, align: 'left', width: 250, editable: true, edittype: 'text', editoptions: { size: 50 } }
        ]
        , rowNum: 10
        , rowList: [10, 20, 30, 50]
        , pager: '#pager2'
        , sortname: 'RowId'
        , viewrecords: true
        , sortorder: "desc"
        , caption: "Visitor Products"
        , rownumbers: false
        , autowidth: true
        , recreateForm: true
        , ondblClickRow: function (rowid, iRow, iCol, e) {
            $("#list2").editGridRow(rowid, prmGridDialog);
        }
    }).navGrid('#pager2',
        { edit: true, add: true, del: true, search: true, refresh: true }
        , updateDialog
        , addDialog
        , deleteDialog
    );
});

不确定我是否遗漏了什么。

4

1 回答 1

0

我的错。prmGridDialog 是一个不存在的变量。该示例是从网站复制的,我一定没有复制变量初始化代码。一旦我指定了一个现有的对话框(在这种情况下是更新),它就起作用了:

var updateDialog = {
    url: '@Url.Action("EditStudentClass", "StudentClasses")'
    , closeAfterEdit: true
    , closeOnEscape: true
    , modal: true
    , width: "400"
};


$("#list2").editGridRow(rowid, updateDialog);

代替

$("#list2").editGridRow(rowid, prmGridDialog);
于 2012-12-18T22:32:40.333 回答