Page 1 of 1

Display filed into subform does not update after add new row ?

Posted: Sun Jun 05, 2022 5:47 pm
by damien
Hello,

I have a sub-form with 2 objects:
- a lookup
- a display

The lookup table contains only foreign key, the labels are into other tables.
I use a dedicated Browser form to help the user navigate into that table and it relations.

The display objects allow me to retrieve the label for the user to see the information linked to the lookup objects.

But it does not works just after adding a new row into the sub form.
Probably because the database is not yet written.
It updates after a save action.
But in-between the user can't understand what he is doing.

So this probably the wrong way to do that but I do not find how to do it ?

Re: Display filed into subform does not update after add new row ?

Posted: Tue Jun 07, 2022 11:45 am
by kev1n
Hi,

The display objects needs refreshing when a value is picked from the lookup. To do so, I added a new JS function nuSubformRefreshDisplayObject().
But it is not quite finished yet.

Re: Display filed into subform does not update after add new row ?

Posted: Tue Jun 07, 2022 12:29 pm
by damien
Hello Kevin,

I have found a workaround that works fine.
Onto the "afterinsertrow" of the Subform I put a call to nuRunPHPHidden on a dedicated PHP procedure.
I have created a hidden PHP procedure to select the same values than the one used into the display object and and a call nuJavascriptCallback to update it into the JS space.

It is a bit complexe but it works fine at the end.

But I will be interested to simplify when the nuSubformRefreshDisplayObject will be ready.

Thanks.

Re: Display filed into subform does not update after add new row ?

Posted: Thu Jun 09, 2022 6:08 am
by kev1n
This is now how to update a display in a subform after a lookup value has been picked with the new function nuSubformRefreshDisplayObject()

Code in LUJS (lookup JS):

Code: Select all

let subformPk = 'nuaccessforms'; // subform's primary key (15-characters unique id) 
let updateObjectId = 'display_obj'; // id of you display object

let prefix = String($('#' + target).attr('data-nu-prefix'));
nuSubformRefreshDisplayObject(prefix, updateObjectId, subformPk);

Re: Display filed into subform does not update after add new row ?

Posted: Mon Jul 18, 2022 8:53 pm
by kev1n
Did that help?