【问题标题】:getting exceptions with jqGrid使用 jqGrid 获取异常
【发布时间】:2013-02-27 08:39:24
【问题描述】:

我正在尝试设置我的 jqGrid 以从 document.ready 上的函数获取数据。不知何故,当我这样做时,我遇到了几个小异常......我最初认为也许我的 json 数据格式错误......

{"total": 2,
"page": 1,
"records": 15,
"rows": [{
    "id": 2148,
    "cell": {
        "MRN": "840134833",
        "Hospital_Fin": "987141516",
        "First_Name": "YELLOW",
        "Last_Name": "CRAYON",
        "Date_of_birth": "\/Date(1253160000000)\/"          
    }
},
{
    "id": 1898,
    "cell": {
        "MRN": "785528039",
        "Hospital_Fin": "6669511596226",
        "First_Name": "RAYFIELD",
        "Last_Name": "BOYD",
        "Date_of_birth": "\/Date(-720298800000)\/"
    }
}]}

但它看起来不错。

我得到了这个异常,例如:

0x800a138f - Microsoft JScript runtime error: Unable to get value of the property 'integer': object is null or undefined

我在代码的以下行得到了那个异常...

fmt = $.jgrid.formatter.integer || {};

我的网格设置如下

    $(document).ready(function () {
        jQuery("#frTable").jqGrid ({
            cmTemplate: { sortable: false },
            caption: '@TempData["POPNAME"]' + ' Population',
            datatype: 'json',
            mtype: 'GET',
            url: '@Url.Action("GetAjaxPagedGridData", "Encounters", new { popId = TempData["POPULATIONID"] })',//'/Encounters/GetAjaxPagedGridData/'+ '',                
            pager: '#pager',
            loadonce: true,
            height: 450,
            gridview: true,
            viewrecords: true,
            rowNum: 15,
            shrinkToFit: false,
            autowidth: true,
            colNames: [...],
            colModel: [
                   { name: 'MRN', width: 125, align: 'left' },
                   { name: 'Hospital_Fin', width: 145, align: 'left' },
                   { name: 'First_Name', width: 115, align: 'left' },
                   { name: 'Last_Name', width: 115, align: 'left' },
                   { name: 'Date_of_birth', width: 145, align: 'left' },]

colNames 和 colModel 不重要。 我的智慧到此为止。这应该有效。我错过了什么?

【问题讨论】:

  • colModel 可能不是那么无关紧要,您是否在其中设置了任何格式化程序?
  • 其实我是我会更新我的帖子...
  • 您是否包含至少一个语言环境文件?
  • 脚本号中没有。
  • 可能是你的问题。

标签: asp.net-mvc-4 jqgrid


【解决方案1】:

您可能缺少定义 $.jqgrid.formatter 的所需语言环境文件:

jqGrid docs

您需要包含 jQuery、jqGrid 插件和 jqGrid 语言环境文件之一才能使其工作,例如:

<script src="js/jquery-1.4.2.min.js" type="text/javascript"></script>
<script src="js/i18n/grid.locale-en.js" type="text/javascript"></script>
<script src="js/jquery.jqGrid.min.js" type="text/javascript"></script>

【讨论】:

  • Microsoft JScript 运行时错误:对象不支持属性或方法 'jqID
  • 就是这样。您还必须确保在 jqGrid 之前导入本地文件。否则你会被抛出一大堆异常。不幸的是,我的数据仍然没有显示。但一次一场战斗。
【解决方案2】:

对我来说,这个错误听起来像是你的视图中的对象没有设置的问题。尝试设置一个静态值,而不是像TempData["POPULATIONID"] 这样的值,我认为你可能会继续前进。

【讨论】:

  • 正在设置中。当我调试并点击该方法时,我看到了值。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-04-28
  • 1970-01-01
相关资源
最近更新 更多