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

nuSubformArray / How to modify fields

Unread post 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(""); 
    }
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 »

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
toms
Posts: 785
Joined: Sun Oct 14, 2018 11:25 am

Re: nuSubformArray / How to modify fields

Unread post by toms »

I see. Is it also possible then to modify its values and write them back.to the grid?
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 »

toms,

There is no function to do that.

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

Re: nuSubformArray / How to modify fields

Unread post 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.
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 »

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
toms
Posts: 785
Joined: Sun Oct 14, 2018 11:25 am

Re: nuSubformArray / How to modify fields

Unread post 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?
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 »

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
toms
Posts: 785
Joined: Sun Oct 14, 2018 11:25 am

Re: nuSubformArray / How to modify fields

Unread post 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.
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 »

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
You do not have the required permissions to view the files attached to this post.
Locked