Welcome to the nuBuilder Forums!

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

Sub form for a subform

Questions related to using nuBuilder Forte.
Post Reply
sandeepgumudelli
Posts: 41
Joined: Thu Jan 25, 2018 3:51 pm

Sub form for a subform

Unread post by sandeepgumudelli »

Hi,

Is it possible to create subform in a subform keeping both of them as grid?

The moment I add second subform to 1st subform nothing coming up. So tried alternative way to keep 1st subform as form and second subform as grid but no luck.

First subform work fine and the moment I add second second subform within first one it is not working as expected.

Regards,
Sandeep
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: Sub form for a subform

Unread post by admin »

Sandeep,

Sorry, not in nuBuilder.

You can only go Edit > Subform eg. 1 to many.

Steven
sandeepgumudelli
Posts: 41
Joined: Thu Jan 25, 2018 3:51 pm

Re: Sub form for a subform

Unread post by sandeepgumudelli »

Thank you for the quick response Steven.
I was thinking of alternative and included Input:Button in subform1 tried to create on click event to trigger subform2. My problem now is i couldn't find where to place click events for buttons. It was little easy in nuBuilder pro but not able to find it in nuBuilder forte.


Regards,
Sandeep
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: Sub form for a subform

Unread post by admin »

Sandeep,

I hope this makes sense...
open_popup.PNG
onclick code...

Code: Select all

if(nuSubformRowId(this)==-1){alert('Must Save Record First...');}else{nuPopup('5a710cd6d4a8f5a',nuSubformRowId(this))}
'5a710cd6d4a8f5a' is the form that will be opened.

Steven
You do not have the required permissions to view the files attached to this post.
sandeepgumudelli
Posts: 41
Joined: Thu Jan 25, 2018 3:51 pm

Re: Sub form for a subform

Unread post by sandeepgumudelli »

Thank you for the help Steven, Hugely appreciated.

With your code I am able to get the onclick working. However, I want the entry in subform to be saved as soon as I click on button for opening the popup form instead of checking if the form is saved or not. I tried the code below and a few variations of it but each time the popup-form opens and closes immediately.

Code: Select all

onclick = function(){nuUpdateData();nuPopup('5a71a4df3061331',nuSubformRowId(this));}
I also tried:

Code: Select all

onclick = function(){nuSaveAction();nuPopup('5a71a4df3061331',nuSubformRowId(this));}
Please can you give some guidance on how I can achieve saving before opening the pop-up form
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: Sub form for a subform

Unread post by admin »

Sandeep,

There is no simple way to save a subform record without saving the main Edit record.

One reason is...

What happens if you click this Subform Button, and the main Edit Form has not yet been saved?

How can a Subform record be saved without knowing what the primary key of the main Edit record is, as it's needed by the Subform record as a foreign key?

How can you be born, when your father hasn't been yet.

I hate being the guy who says "That's impossible" but I can't think of a way to do it.

Steven
sandeepgumudelli
Posts: 41
Joined: Thu Jan 25, 2018 3:51 pm

Re: Sub form for a subform

Unread post by sandeepgumudelli »

Hi Steven,

Many thanks for your help. Actually I am not trying to save the subform ahead of main form being saved. What I am trying to do is save the mainform at the click of this button and open the subform after that.

When I try saving the form with if statement as you gave in first example just by replacing the alert with SaveAction() function, it does save the main form and second click on the button opens the subform without any issues. Problem is that if am combining the two functions for save and popup, it saves, opens the pop-up but then closes it pretty much immediately.

Do you think what I am trying to do is also not possible?

Regards,
Sandeep.
toms
Posts: 785
Joined: Sun Oct 14, 2018 11:25 am

Re: Sub form for a subform

Unread post by toms »

Sandeep,

I think it could be a timing issue. If you wait like 2 seconds after saving the form/before opening the pop-up, will it work?

You could try it with this code:

Code: Select all

nuSaveAction();
setTimeout(function() {
   nuAfterSave();
 }, 2000);

function nuAfterSave() {
    // code to open your pop-here
}
Of course, it would be better if there was a native nuAfterSave() event so you wouldn't have to rely on a timeout.
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: Sub form for a subform

Unread post by admin »

Sandeep,

The best way to do what you are trying to do is this...


You could try this on the Button...

Code: Select all


if(nuSubformRowId(this)==-1){
   alert('Must Save Record First...');
}else{
   window.subform_record_id= nuSubformRowId(this);
   nuSaveAction();
}
It will Save the Edit Record and when the whole Form is reloaded the Form's Javascript is rerun so if you,

add this to the Form's Javascript...

Code: Select all

if(window.subform_record_id != ''){
   nuPopup('5a710cd6d4a8f5a',window.subform_record_id)
   window.subform_record_id = '';
}
After the Edit Form has reloaded it will bring up the Popup.

BUT THIS STILL WON'T WORK if the nuSubformRowId(this) returns -1 (hasn't been saved yet)

So its actually just a long way of doing the same thing, that won't work.



You really need to know an ID.

Another (flawed) way could be to save the row number and when the Form reloads you could try to get the id from its reloaded Subform object. eg...

http://wiki.nubuilder.net/nubuilderfort ... formObject

Code: Select all

nuSubformObject('zzzzsys_tab_sf').rows[clicked_row_number][0]
But then you have to hope nothing has been deleted or reordered - and that it's still the correct row number.


Steven
Post Reply