获取0x800a01b6 - JavaScript运行时错误:对象不支持属性或方法'jqGrid'

时间:2013-11-21 04:49:21

标签: 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>

点击后获得以下错误 在编辑弹出窗口中提交(在提交行后的编辑选项上)

  

“Link”

中第602行第602行未处理的异常      

0x800a01b6 - JavaScript运行时错误:对象不支持属性或方法'jqGrid'

1 个答案:

答案 0 :(得分: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放在正文的底部