easyui1.4.2 Formatter processing JSON inline data undefined

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.