easyui1.4.2 formatter处理json内嵌数据undefined
2015-07-03 16:52
591 查看
问题描述:
easyui升级到1.4.2后,原来使用的获取json嵌套数据的函数“formatter: function (value,row) { return row.business.region }”不好使了,datagrid初始化加载数据的时候,会报错提示“region” undefined,数据无法正常显示。
原因:
The 'formatter' function is called by $.fn.datagrid.defaults.view.renderRow. At the first time, the datagrid will call 'renderRow' with empty row data to render an empty row.
formatter函数第一遍加载的时候,datagrid会调用renderRow方法,这时候各行数据还没有加载,向formatter传递的是一个空行,所以“row.business.region”中的“region”为undefined。(不知道理解的对不对~)
解决方案:
If you really want to prevent the 'formatter' function from calling more than once, please override the 'renderEmptyRow' function of view to solve this issue.
简单说就是重写easyui的renderEmptyRow方法,代码如下:(亲测可用~~)
参考:
http://www.jeasyui.com/forum/index.php?topic=4572.0
(友情提示:访问该链接可能需要翻墙~~)
easyui升级到1.4.2后,原来使用的获取json嵌套数据的函数“formatter: function (value,row) { return row.business.region }”不好使了,datagrid初始化加载数据的时候,会报错提示“region” undefined,数据无法正常显示。
原因:
The 'formatter' function is called by $.fn.datagrid.defaults.view.renderRow. At the first time, the datagrid will call 'renderRow' with empty row data to render an empty row.
formatter函数第一遍加载的时候,datagrid会调用renderRow方法,这时候各行数据还没有加载,向formatter传递的是一个空行,所以“row.business.region”中的“region”为undefined。(不知道理解的对不对~)
解决方案:
If you really want to prevent the 'formatter' function from calling more than once, please override the 'renderEmptyRow' function of view to solve this issue.
简单说就是重写easyui的renderEmptyRow方法,代码如下:(亲测可用~~)
(function($){ var renderEmptyRow = $.fn.datagrid.defaults.view.renderEmptyRow; $.extend($.fn.datagrid.defaults.view, { renderEmptyRow:function(target){ var fields = $(target).datagrid('getColumnFields'); for(var i=0; i<fields.length; i++){ var col = $(target).datagrid('getColumnOption', fields[i]); col.formatter1 = col.formatter; col.styler1 = col.styler; col.formatter = col.styler = undefined; } renderEmptyRow.call(this, target); for(var i=0; i<fields.length; i++){ var col = $(target).datagrid('getColumnOption', fields[i]); col.formatter = col.formatter1; col.styler = col.styler1; col.formatter1 = col.styler1 = undefined; } } }) })(jQuery);
参考:
http://www.jeasyui.com/forum/index.php?topic=4572.0
(友情提示:访问该链接可能需要翻墙~~)
相关文章推荐
- Building modules for a precompiled kernel
- 包装ServletRequest和ServletResponse
- rqt install in Fuerte / git target directories
- UILabel 设置不同颜色,不同字体
- IOS入门学习笔记(普通UI控件--UILabel)
- JS 前端框架8 require.js使用
- Failed to convert property value of type [java.lang.String] to required type [java.util.Date] for pr
- 【Streaming】我在拓扑中使用了Ack机制,为什么在Storm UI上有大量Failed数据?
- JS 前端框架7 一个简单的require功能
- Easy Ui 加Loading
- error C2440: ’static_cast’ : cannot convert from ‘UINT (__thiscall CStaticLink::* )(CPoint)’ to ‘LRE
- Andriod UiAutomator 使用 Jenkins 实现持续集成
- NFinal学习笔记 02—NFinalBuild
- IOS自动化测试之UIAutomation Test学习——first step:Instrument
- NSOperationQueue和GCD的区别,以及在什么场合下使用
- Android酷炫实用的开源框架(UI框架)
- 主动呼叫KVO(NSKeyValueObserverNotification)
- 关于${pageContext.request.contextPath}的理解
- FlexBuilder无法连接Flashplayer调试器进行DEBUG
- ARP协议详解之Gratuitous ARP(免费ARP)