Welcome to the nuBuilder Forums!

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

nuSubformArray / How to modify fields

Questions related to using nuBuilder Forte.
toms
Posts: 785
Joined: Sun Oct 14, 2018 11:25 am

Re: nuSubformArray / How to modify fields

Unread post by toms »

Thanks Steven, this will help me get started.
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: nuSubformArray / How to modify fields

Unread post by admin »

.
alf1976
Posts: 75
Joined: Tue Dec 26, 2017 8:58 pm

Re: nuSubformArray / How to modify fields

Unread post by alf1976 »

To extend Toms query

i need the ability to update subforms based upon the main form

My main form contains the quantities for the estimate. If they change i need the ability to go into each subform and update various calcuations to recalcuate costs

The calcuations are not straight forward, so if on a main form i would have functions to process these and update other fields. On a subform the Javascript is grey out.

i could get around this by having the calculation functions on the main form. An onchange from a subform object does fire on the main form, but this isnt much help as as i cannot see any way of
knowing which record actually sent it (and even if i did there isnt a function to manipulate subform data)

Is this something that can be looked at in the future?
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: nuSubformArray / How to modify fields

Unread post by admin »

Andrew,

You can do whatever you like already.

You don't have to use Calc Objects to add stuff up.

If you have something complex, use a readonly, Input:nuNumber Object and set its value to whatever you want with Javascript.

Steven
toms
Posts: 785
Joined: Sun Oct 14, 2018 11:25 am

Re: nuSubformArray / How to modify fields

Unread post by toms »

alf1976 wrote: An onchange from a subform object does fire on the main form, but this isnt much help as as i cannot see any way of
knowing which record actually sent it
Add an onchange event handler to your subform objects and pass the event parameter to retrieve the sender-control from the passed event parameter.
onchangehandler.PNG
In you main form, add this js event handler:

Code: Select all

function myOnChangeHandler(event) {
//   console.log(event.target);
// add the code from below
}
alf1976 wrote: (and even if i did there isnt a function to manipulate subform data)
Then you can retrieve information about the target object (name, subform, row number) and change other fields that are on the same row.

e.g. (untested!)

Code: Select all

var t	= $('#' + event.target.id)[0];
var p	= $('#' + t.id).attr('data-nu-prefix'); // field that triggered the event
var s           = event.target.attr('data-nu-form'); // subform
var n          = p.substr(p.length - 3); // extract the row number

var field = 'myotherfield';
$('#' + subform + nuPad3(n) + field).val('hello!').change();
I hope that helps.
You do not have the required permissions to view the files attached to this post.
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: nuSubformArray / How to modify fields

Unread post by admin »

Andrew,

If we are understanding your question correctly...

Code: Select all


function myOnChangeHandler(e) {

   var p   = $('#' + e.target.id).attr('data-nu-prefix');
   var f   = "myotherfield";

   $('#' + p + f).val('hello!').change();

}

alf1976
Posts: 75
Joined: Tue Dec 26, 2017 8:58 pm

Re: nuSubformArray / How to modify fields

Unread post by alf1976 »

You guys are always good for a solution. I’ll give it a go and see how I get on
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: nuSubformArray / How to modify fields

Unread post by admin »

.
Locked