Welcome to the nuBuilder Forums!

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

subforms and display object Topic is solved

Questions related to using nuBuilder Forte.
Post Reply
yvesf
Posts: 305
Joined: Sun Mar 14, 2021 8:48 am
Location: Geneva
Has thanked: 83 times
Been thanked: 11 times

subforms and display object

Unread post by yvesf »

hi,

I have a form with a subform showing payments (amount and type: checks, cash, credit card).
I calculate the total in a "calc" object and totals per payment type in "display" objects.
I want these totals in the parent browse form, but "display" values aren’t stored in the database and can’t be shown there.
How can I display the overall total and totals per payment type in the browse form?
Is there an object like "display" that saves calculations to the database for use in the browse form query, or
........another solution?
thx,

Yves
steven
Posts: 359
Joined: Mon Jun 15, 2009 10:03 am
Has thanked: 48 times
Been thanked: 47 times

Re: subforms and display object

Unread post by steven »

Yves,

Can you share your database with us?


Steven
If you like nuBuilder, how about leaving a nice review on SourceForge?
Gnu
Posts: 14
Joined: Fri Jan 07, 2022 10:38 am
Has thanked: 51 times

Re: subforms and display object

Unread post by Gnu »

Maybe you can use PHP code in the “After Save” event to write the value directly to the database:

Code: Select all

// In the “After Save” tab of the form
$displayValue = nuGetValue('object_id'); // Get the value of the display object
$recordId = $GLOBALS['nu_record']['id']; // Primary key of the current data record

if ($displayValue !== null) {
    nuRunQuery("UPDATE table SET display = ? WHERE id = ?”, [$displayValue, $recordId]);
}
nuGetValue('object_id') retrieves the current value of an object from the form.
$GLOBALS['nu_record']['id'] contains the ID of the currently saved record (make sure your table has an id field).

(not tested)
kev1n
nuBuilder Team
Posts: 4242
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 68 times
Been thanked: 422 times
Contact:

Re: subforms and display object

Unread post by kev1n »

yvesf wrote: Thu Mar 06, 2025 12:58 am but "display" values aren’t stored in the database and can’t be shown there.
Values of Display objects are stored in the database if you add the "nuEdited" class.

E.g.

Code: Select all

$('#display_object_id').addClass('nuEdited');
yvesf
Posts: 305
Joined: Sun Mar 14, 2021 8:48 am
Location: Geneva
Has thanked: 83 times
Been thanked: 11 times

Re: subforms and display object

Unread post by yvesf »

I have put this code on the nuload event , custom tab of the related display object. It works !!! How can I update all the records without having to open records one by one and save it on previous records prior to this change ?

Yves
kev1n
nuBuilder Team
Posts: 4242
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 68 times
Been thanked: 422 times
Contact:

Re: subforms and display object

Unread post by kev1n »

Write an SQL Query that will calculate and update the totals.
Post Reply