nuSubformArray / How to modify fields

Questions related to using nuBuilder Forte.

nuSubformArray / How to modify fields

Postby toms » Fri Jan 12, 2018 2:41 pm

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("");
    }
toms
toms
 
Posts: 402
Joined: Wed Nov 08, 2017 8:57 pm

Re: nuSubformArray / How to modify fields

Postby admin » Sat Jan 13, 2018 4:17 am

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/nubuilderforte/index.php/Javascript#nuSubformObject
http://wiki.nubuilder.net/nubuilderforte/index.php/PHP#nuSubformObject


Steven
admin
Site Admin
 
Posts: 2467
Joined: Mon Jun 15, 2009 9:53 am

Re: nuSubformArray / How to modify fields

Postby toms » Sat Jan 13, 2018 4:21 am

I see. Is it also possible then to modify its values and write them back.to the grid?
toms
toms
 
Posts: 402
Joined: Wed Nov 08, 2017 8:57 pm

Re: nuSubformArray / How to modify fields

Postby admin » Sat Jan 13, 2018 4:38 am

toms,

There is no function to do that.

Steven
admin
Site Admin
 
Posts: 2467
Joined: Mon Jun 15, 2009 9:53 am

Re: nuSubformArray / How to modify fields

Postby toms » Sat Jan 13, 2018 6:00 am

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.
toms
toms
 
Posts: 402
Joined: Wed Nov 08, 2017 8:57 pm

Re: nuSubformArray / How to modify fields

Postby admin » Sat Jan 13, 2018 7:34 am

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/nubuilderforte/index.php/Objects#Tab_-_Custom_Code

Steven
admin
Site Admin
 
Posts: 2467
Joined: Mon Jun 15, 2009 9:53 am

Re: nuSubformArray / How to modify fields

Postby toms » Sun Jan 14, 2018 7:38 pm

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?
Attachments
afterinsertrow.PNG
afterinsertrow.PNG (8.37 KiB) Viewed 303 times
toms
toms
 
Posts: 402
Joined: Wed Nov 08, 2017 8:57 pm

Re: nuSubformArray / How to modify fields

Postby admin » Mon Jan 15, 2018 2:02 am

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
admin
Site Admin
 
Posts: 2467
Joined: Mon Jun 15, 2009 9:53 am

Re: nuSubformArray / How to modify fields

Postby toms » Tue Jan 16, 2018 9:53 am

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.
toms
toms
 
Posts: 402
Joined: Wed Nov 08, 2017 8:57 pm

Re: nuSubformArray / How to modify fields

Postby admin » Tue Jan 16, 2018 9:30 pm

toms,

Add an Event, as below...

afterinsertrow2.png
afterinsertrow2.png (39.34 KiB) Viewed 270 times


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
admin
Site Admin
 
Posts: 2467
Joined: Mon Jun 15, 2009 9:53 am

Next

Return to General