Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

browse_total_rows

Questions related to customising nuBuilder Forte with JavaScript or PHP.
kev1n
nuBuilder Team
Posts: 4305
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 446 times
Contact:

Re: browse_total_rows

Unread post by kev1n »

As a quick workaround, try this:

Replace this line

Code: Select all

 tCell.html('<b>' + nuFORM.addFormatting(result, f) + '</b>'); 
with this code:

Code: Select all

 tCell.html('<b>' + result.toFixed(1); + '</b>');
kknm
Posts: 366
Joined: Sat Apr 11, 2020 12:03 am
Has thanked: 3 times
Been thanked: 4 times
Contact:

Re: browse_total_rows

Unread post by kknm »

Why is this not observed in other columns?
kknm
Posts: 366
Joined: Sat Apr 11, 2020 12:03 am
Has thanked: 3 times
Been thanked: 4 times
Contact:

Re: browse_total_rows

Unread post by kknm »

kev1n wrote:As a quick workaround, try this:

Replace this line

Code: Select all

 tCell.html('<b>' + nuFORM.addFormatting(result, f) + '</b>'); 
with this code:

Code: Select all

 tCell.html('<b>' + result.toFixed(1); + '</b>');
Inserted so:

Code: Select all

 tCell.html('<b>' + result.toFixed(1) + '</b>');[/code
It worked
One more question
It seems that no one is moderating the “Reports” forum thread, maybe you will answer my question in that thread?
kev1n
nuBuilder Team
Posts: 4305
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 446 times
Contact:

Re: browse_total_rows

Unread post by kev1n »

kknm wrote:Why is this not observed in other columns?
Well, nuBuilde just trims off the additional decimal places. It could be that the mathematically rounded result is identical to the truncated result in the other columns.
kev1n
nuBuilder Team
Posts: 4305
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 446 times
Contact:

Re: browse_total_rows

Unread post by kev1n »

If you're looking for a "real fix", you could also try patching nuformclass.js directly

Replace this line:

Code: Select all

var s		= String(d + String(0).repeat(100)).substr(0, F.places).trim();
With this one:

Code: Select all

var s = Number('0.'+ d).toFixed(F.places).slice(2);

I did not do exhaustive testing, but it seemed to work. I.e. the rounding is correct now.
(You have to log in again after the change)
kknm
Posts: 366
Joined: Sat Apr 11, 2020 12:03 am
Has thanked: 3 times
Been thanked: 4 times
Contact:

Re: browse_total_rows

Unread post by kknm »

I will definitely try your recommendations.
I want to clarify - can I take out browse_total_rows.js in a separate procedure to access it from different forms?
kev1n
nuBuilder Team
Posts: 4305
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 446 times
Contact:

Re: browse_total_rows

Unread post by kev1n »

Sure, you can do that by including the JavaScript as an external file.

To do so,

1. Create a new folder (e.g.) /libs in the root directory of nuBuilder and place the browse_total_rows.js file there.
2. Include the file in the header field. (Setup -> Header)
setup_header.jpg

Code: Select all

</script>

<script src='libs/browse_total_rows.js' type='text/javascript'></script>
You do not have the required permissions to view the files attached to this post.
kknm
Posts: 366
Joined: Sat Apr 11, 2020 12:03 am
Has thanked: 3 times
Been thanked: 4 times
Contact:

Re: browse_total_rows

Unread post by kknm »

kev1n wrote:If you're looking for a "real fix", you could also try patching nuformclass.js directly

Replace this line:

Code: Select all

var s		= String(d + String(0).repeat(100)).substr(0, F.places).trim();
With this one:

Code: Select all

var s = Number('0.'+ d).toFixed(F.places).slice(2);

I did not do exhaustive testing, but it seemed to work. I.e. the rounding is correct now.
(You have to log in again after the change)
I tried this with the original browse_total_rows, but that didn't work.
Then I tried this with the correct browse_total_rows, it works correctly,although, it seems, without nuformclass.js it was correct.
kev1n
nuBuilder Team
Posts: 4305
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 446 times
Contact:

Re: browse_total_rows

Unread post by kev1n »

kknm wrote:I tried this with the original browse_total_rows, but that didn't work.
What do you mean, it didn't work? It works for me just fine. After the change you have to log in again.
kknm
Posts: 366
Joined: Sat Apr 11, 2020 12:03 am
Has thanked: 3 times
Been thanked: 4 times
Contact:

Re: browse_total_rows

Unread post by kknm »

Yes, the original script now works correctly. I remember exactly that I was leaving nubuilder.
It seems that only after turning off the computer did it work.
Post Reply