Welcome to the nuBuilder Forums!
Register and log in to access exclusive forums and content available only to registered users.
Register and log in to access exclusive forums and content available only to registered users.
nuSubformArray / How to modify fields
-
- Posts: 785
- Joined: Sun Oct 14, 2018 11:25 am
-
- Posts: 75
- Joined: Tue Dec 26, 2017 8:58 pm
Re: nuSubformArray / How to modify fields
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?
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?
Re: nuSubformArray / How to modify fields
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
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
-
- Posts: 785
- Joined: Sun Oct 14, 2018 11:25 am
Re: nuSubformArray / How to modify fields
Add an onchange event handler to your subform objects and pass the event parameter to retrieve the sender-control from the passed event parameter.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
In you main form, add this js event handler:
Code: Select all
function myOnChangeHandler(event) {
// console.log(event.target);
// add the code from below
}
Then you can retrieve information about the target object (name, subform, row number) and change other fields that are on the same row.alf1976 wrote: (and even if i did there isnt a function to manipulate subform data)
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();
You do not have the required permissions to view the files attached to this post.
Re: nuSubformArray / How to modify fields
Andrew,
If we are understanding your question correctly...
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();
}
-
- Posts: 75
- Joined: Tue Dec 26, 2017 8:58 pm
Re: nuSubformArray / How to modify fields
You guys are always good for a solution. I’ll give it a go and see how I get on