2013-11-21 34 views
-1

下面是我的代碼:獲取0x800a01b6 - JavaScript的運行時錯誤:對象不支持屬性或方法「的jqGrid」

<script type="text/javascript"> 
    $("#Employee-grid-array").jqGrid({ 
       datatype: "xml", 
       mtype: 'json', 
       rowNum: 1, 
       url:'/DebitCredit/Index', 
       rowList: [1, 2, 4, 5, 10], 
       colNames: ['Account', 'Tranaction No', 'Transaction Date', 'Status', 'Landfill Site', 'Transaction Amount', 'Vat Amount', 'Weight', 'Remarks' 
       , 'Created by', 'Created Date'], 
       colModel: [ 
         { name: 'Account_No', index: 'Account_No', width: 100, editable: true }, 
         { name: 'Tran_No', index: 'Tran_No', width: 100, editable: true }, 
         { name: 'Tran_Date', index: 'Tran_Date', width: 150, editable: true }, 
         { name: 'Status_QC', index: 'Status_QC', width: 50 }, 
         { name: 'Landfill_Site_ID', index: 'Landfill_Site_ID', width: 100, editable: true }, 
         { name: 'Tran_Amount', index: 'Tran_Amount', width: 100, editable: true }, 
         { name: 'Vat_Amount', index: 'Vat_Amount', width: 100, editable: true }, 
         { name: 'Weight', index: 'Weight', width: 70, editable: true }, 
         { name: 'Remarks', index: 'Remarks', width: 70, editable: true }, 
         { name: 'Created_By', index: 'Created_By', width: 100 }, 
         { name: 'Created_Date', index: 'Created_Date', width: 100 }, 
       ], 
       pager: jQuery('#pagernav'), 
       multiselect: true, 
       viewrecords: true, 
       shrinkToFit: false 
      }).navGrid('#pagernav', { edit: true, add: true, del: true }, 
     // Edit options 
      { 
       savekey: [true, 13], 
       reloadAfterSubmit: true, 
       jqModal: false, 
       closeOnEscape: true, 
       closeAfterEdit: true, 
       url: "/DebitCredit/Edit", 
       closeAfterSubmit: true, 
       afterSubmit: function() { 
        $("#Employee-grid-array").jqGrid('setGridParam', { datatype: 'json' }).trigger('reloadGrid') 
       } 
      }, 
     // Add options 
      { 
       url: '/DebitCredit/Create', closeAfterAdd: true, reloadAfterSubmit: true 
      }, 
     // Delete options 
       { 
        url: '/DebitCredit/Remove', 
        jqModal: false, 
        serializeDelData: function (postdata) { 

         return { id: postdata.Tran_No,test:"test" }; // the body MUST be empty in DELETE HTTP requests 
        }, 

        afterSubmit: function (response, postdata) { 
         var rowdata = $('#Employee-grid-array').getRowData(postdata.Account_No); 
         return { Name: postdata.Tran_No, test: "test" }; 

        } 
       }, 
       { 

        closeOnEscape: true, multipleSearch: true, 
        closeAfterSearch: true 
       } 
       ); 
</script> 

獲得以下錯誤點擊 後在編輯彈出提交(在編輯選項afterSubmit線)

Unhandled exception at line 602, column 21 in "Link"

0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'jqGrid'

回答

1

似乎你缺少你的jQuery和/或jQuery網格聲明。我把你的代碼放在你的腳本上面

<link href="//cdn.jsdelivr.net/jqgrid/4.5.2/css/ui.jqgrid.css"></script> 
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script> 
<script src="//cdn.jsdelivr.net/jqgrid/4.5.2/jquery.jqGrid.js"></script> 

它並沒有拋出你的錯誤 - 我沒有嘗試連接任何東西。對於最佳做法,它建議您將CSS放入並將javascript放在主體底部

相關問題