Problem Description:
Easyui after upgrading to 1.4.2, the function "Formatter:function (value,row) {return row. business.region}" used to get JSON nested data is not good enough, When the DataGrid initializes the data, the error message "Region" Undefined, the data is not displayed properly.
Reason:
The ' formatter ' function is a called by $.fn.datagrid.defaults.view.renderrow. At the first time, the DataGrid would call ' Renderrow ' with empty row data to render an empty row.
formatter function The first time load, datagrid will call renderrow method, when the rows of data have not yet loaded, to formatter is passed a blank line, so ".business.region "" region "is undefined . (I don't know if I understand the right ~)
Solution:
if you really want to prevent the ' formatter ' function from calling + than once, please override the ' Renderemptyrow ' Function of view to solve this issue.
renderemptyrow method, the code is as follows: ( Pro Test Available ~ ~ )
(function ($) {var Renderemptyrow = $.fn.datagrid.defaults.view.renderemptyrow;$.extend ($.fn.datagrid.defaults.view {renderemptyrow:function (target) {var fields = $ (target). The 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); (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);
Reference:
http://www.jeasyui.com/forum/index.php?topic=4572.0
(Friendly tip: access to the link may need to turn over the Wall ~ ~)
easyui1.4.2 Formatter processing JSON inline data undefined