change number format in Attribute table widget code

666
1
07-18-2017 01:30 PM
NadiaTargulian
New Contributor II

Junshan Liu

Hi Junshan,

I was wondering if it is possible to change number format in Attribute table widget code ( I need to format a number with 2 digits after the decimal point)   I think I need to change code here:

getFormattedNumber: function(num, format)   in the utils.js but not sure it is a right place. Could you point me in the right direction?

Thank you.

using WAB Dev 2.4

0 Kudos
1 Reply
NadiaTargulian
New Contributor II

I actually figured it out.

 It involves changing a number of places after decimal point in jimu.js/utils.js

I changed places: p to places: 2 in this function:

mo.localizeNumberByFieldInfo = function(n, fieldInfo) {

    var fn = null;

    var p = lang.exists('format.places', fieldInfo) && fieldInfo.format.places;

    fn = mo.localizeNumber(n, {

      places: 2

    });

 

    if (lang.exists('format.digitSeparator', fieldInfo) && !fieldInfo.format.digitSeparator) {

      return fn.toString().replace(new RegExp('\\' + nlsBundle.group, "g"), "");

    } else {

      return fn;

    }

  };

 

Hope it will help someone who had the same issue!

0 Kudos