Page 1 of 2
nuSubformArray / How to modify fields
Posted: Fri Jan 12, 2018 6:11 am
by toms
Hi,
In nuBuilderPro I use nuSubformArray() and loop through the subform to obtain the Prefix keys in order to retrieve and set values.
How can I set values in nuBuilderForte?
Code: Select all
var subFormPrefixes = nuSubformArray('nuSubFormXYZ', false);
for (var index in subFormPrefixes) {
//e.g. obtaining a value:
var ddate = $('#' + subFormPrefixes[index] + 'absdates_date').val();
// Set a value..
$('#' + subFormPrefixes[index] + 'absdates_hours').val("");
}
Re: nuSubformArray / How to modify fields
Posted: Fri Jan 12, 2018 7:47 pm
by admin
toms,
It's a lot simpler in Forte.
nuSubformObject() will give you an object that has all formatting removed (from Input:nuNumber Objects) that you can loop through.
It also has properties within it that can be used as the data for Google graphs creates with the HTML Object.
.chartData
.chartDataPivot
nuSubformObject() is both a Javascript and PHP function.
http://wiki.nubuilder.net/nubuilderfort ... formObject
http://wiki.nubuilder.net/nubuilderfort ... formObject
Steven
Re: nuSubformArray / How to modify fields
Posted: Fri Jan 12, 2018 7:51 pm
by toms
I see. Is it also possible then to modify its values and write them back.to the grid?
Re: nuSubformArray / How to modify fields
Posted: Fri Jan 12, 2018 8:08 pm
by admin
toms,
There is no function to do that.
Steven
Re: nuSubformArray / How to modify fields
Posted: Fri Jan 12, 2018 9:30 pm
by toms
I see. I need to figure out a way to do it. Since I need to set some default values after adding a row / multiple rows by code.
Re: nuSubformArray / How to modify fields
Posted: Fri Jan 12, 2018 11:04 pm
by admin
toms,
You said....
I need to set some default values after adding a row
nuBuilder Forte has 2 event functions for Subform Objects, one of which you can use to prepopulate Objects in new rows
afterinsertrow...
http://wiki.nubuilder.net/nubuilderfort ... ustom_Code
Steven
Re: nuSubformArray / How to modify fields
Posted: Sun Jan 14, 2018 11:08 am
by toms
I'm not sure how to implement it. Adding an afterinsertrow event handler in the subform object doesn't fire the js.
Adding an afterinsertrow in the main form directly doesn't help either.
And, what are the parameters of that function. I need to get a reference to the inserted row.
Could you shed a light on this?
Re: nuSubformArray / How to modify fields
Posted: Sun Jan 14, 2018 5:32 pm
by admin
toms,
Event is a nuScroll Object that you can scroll up and down in (giving you different events).
I think what you have done is typed it in manually and it needs to be all lowercase.
Try that.
Steven
Re: nuSubformArray / How to modify fields
Posted: Tue Jan 16, 2018 1:23 am
by toms
afterinsertrow fires now.
you can use to prepopulate Objects in new rows afterinsertrow...
How can I do that? After adding a new row, some default values should be set in the new row.
Re: nuSubformArray / How to modify fields
Posted: Tue Jan 16, 2018 1:00 pm
by admin
toms,
Add an Event, as below...
afterinsertrow2.png
And this to the Javascript of the Form...
Code: Select all
function fillNewRow(){
var r = nuSubformObject('sf').rows.length - 1;
$('#sf' + nuPad3(r) + 'field00').val('hello');
$('#sf' + nuPad3(r) + 'field01').val('world');
}
Steven