2012-12-18 61 views
1

我收到錯誤:的jqGrid雙擊項目不工作

微軟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 
    ); 
}); 

不知道如果我失去了一些東西。

回答

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);