Page 1 of 4

browse_total_rows

Posted: Wed Apr 29, 2020 9:06 pm
by kknm
error.PNG
Used browse_total_rows from nuBuilder4-Code-Library.
I have a strange output in 1 column(SUM), with the same formats in other columns (input=Number).

Re: browse_total_rows

Posted: Thu Apr 30, 2020 4:52 am
by kev1n
The image is not displayed. Can you upload it again?

Re: browse_total_rows

Posted: Thu Apr 30, 2020 10:45 am
by kknm
kev1n wrote:The image is not displayed. Can you upload it again?
Uploaded a new one, sorry I have not yet mastered the forum

Re: browse_total_rows

Posted: Thu Apr 30, 2020 11:37 am
by kev1n
What output do you get when you enter this in the developer console (Press F12 to bring up the browser's Developer Console)

Code: Select all

window.nuFORM.getCurrent().browse_columns[2].format

Re: browse_total_rows

Posted: Thu Apr 30, 2020 12:43 pm
by kknm
kev1n wrote:What output do you get when you enter this in the developer console (Press F12 to bring up the browser's Developer Console)

Code: Select all

window.nuFORM.getCurrent().browse_columns[2].format
in console - ""
Even when choosing a format, the sum in the first calculated column is float, in the rest the integer

Re: browse_total_rows

Posted: Thu Apr 30, 2020 12:56 pm
by kev1n
Please also run this code in the dev. console and post the output here:

Code: Select all

var c = window.nuFORM.getCurrent().browse_columns;
var x = "";
for (var index = 0; index < c.length; ++index) {
    x = x + "\n Column " + index + " : " + c[index].format;
}
alert(x);

Re: browse_total_rows

Posted: Thu Apr 30, 2020 1:35 pm
by kknm
kev1n wrote:Please also run this code in the dev. console and post the output here:

Code: Select all

var c = window.nuFORM.getCurrent().browse_columns;
var x = "";
for (var index = 0; index < c.length; ++index) {
    x = x + "\n Column " + index + " : " + c[index].format;
}
alert(x);
Screenshot .PNG

Re: browse_total_rows

Posted: Thu Apr 30, 2020 2:33 pm
by kev1n
It looks like no number format was selected.

https://streamable.com/3ckatd

Re: browse_total_rows

Posted: Thu Apr 30, 2020 3:06 pm
by kknm
kev1n wrote:It looks like no number format was selected.

https://streamable.com/3ckatd
Did everything by reference, but the sum = 3226.2, although it should be 3226.3

Re: browse_total_rows

Posted: Thu Apr 30, 2020 3:34 pm
by kev1n
kknm wrote:
kev1n wrote:It looks like no number format was selected.

https://streamable.com/3ckatd
Did everything by reference, but the sum = 3226.2, although it should be 3226.3
That's because nuBuilder's addFormatting() does not round correctly from a mathematical point of view. It just trims off the additional decimal places.

Code: Select all

nuFORM.addFormatting(3226.29, "N|1000.0")
outputs 3226.2

but

Code: Select all

(3226.29).toFixed(1);
rounds to 3226.3