关于"Uncaught TypeError: Cannot read property 'time' of null"的处理
2017-09-29 15:44
831 查看
今天在做心电文件查询和绘图时遇到一个很奇怪的问题,使用canvas画的心电图出来了,可是easyui的datagrid数据风格却提示没有数据。使用谷歌浏览器调试时console提示下面的错误信息:jquery.easyui.min.js:741 Uncaught TypeError: Cannot read property 'time' of null
这就纳闷了,明明可是画图出来,datagrid却加载不了数据。后来我使用别的账号登录进去,datagrid和绘图都是同步加载出来的,那就说明一个问题,原先那个账号的数据有问题。然后我一个数据一个数据测试,果然发现一条数据最后结果是json=[null],其他数据都正常,可以实现同步加载。
因为后台我是返回json的字符串给前端的easyui框架,easyui捕捉到的json数组的数据中包含有null的对象,所以最后一条数据都不加载。
同时,在加载column数据时,如果这样写,当值为0时,datagrid也不予显示:
field: "nAverageHR",
title: "心率",
width: 140,
align: "center",
/formatter: function(val){
if(val ){
return "<label>" +val+ "</label>";
}
return "";
}
需要对val的值作判断,不同情形进入对应的return,才会显示。
当数据库中有多条数据,有一条数据的文件大小为0,或服务器目录不存在这个文件,都有可能会导致json=[null]的情况,解决方法是用sql语句删除有问题的那条数据,如我的是20170414这一天的这条数据有问题,删掉后,其他日期的数据就可以正常显示了。
相关文章推荐
- 安卓Webview 加载网页 Uncaught TypeError: Cannot read property 'getItem' of null",
- js事件处理程序 Uncaught TypeError: Cannot read property 'addEventListener' of null
- 关于js Uncaught TypeError: Cannot read property 'style' of null 问题
- Uncaught TypeError: Cannot read property 'offsetTop' of null
- Uncaught TypeError: Cannot read property 'prototype' of null using Openerp 7.0
- Uncaught TypeError: Cannot read property 'hasOwnProperty' of null
- 关于Uncaught TypeError: Cannot set property 'onClick' of null。的问题
- Uncaught TypeError: Cannot read property 'length' of null
- Uncaught TypeError: Cannot read property 'querySelector' of null
- Uncaught TypeError: Cannot read property 'value' of null
- Uncaught TypeError: Cannot read property 'getItem' of null
- Uncaught TypeError: Cannot read property 'value' of null
- JavaScript:Uncaught TypeError Cannot read property 'id' of null。
- discuz 出现了Uncaught TypeError: Cannot read property 'appendChild' of null
- 泪的教训!"Uncaught TypeError: Cannot set property 'value' of null"
- canvas出现Uncaught TypeError: Cannot read property 'getContext' of null 错误
- Uncaught TypeError: Cannot read property of 'name' null
- 在使用renderTo中遇到的Uncaught TypeError: Cannot read property 'insertAdjacentHTML' of null
- 在开发Ext 项目中如果遇到 Uncaught TypeError: Cannot read property 'insertAdjacentHTML' of null
- Uncaught TypeError: Cannot read property 'click' of null问题的解决