Welcome to the nuBuilder forums!

Please register and login to view forums and other content only available to registered users.

Navigating from a subform row to the associated record

Post Reply
cpenton
Posts: 2
Joined: Tue Apr 04, 2017 11:16 am

Navigating from a subform row to the associated record

Unread post by cpenton »

Hi,

I'm new to nuBuilderpro and have been struggling with the placement of a button on a subform grid to navigate to the associated record form.

The database structure I have is:
table_1 -(1)--(M)-> table_2 -(1)--(M)-> table_3

My first form shows table_1 records with a subform from table_2. I want to add a button to the table_2 subform to navigate to a form that shows records from table_2 with a subform from table_3. The individual forms work as expected.

When I place a button on the table_2 subform it appears that the "#SUBFORM_RECORD_ID#" hash variable is not expanded in the "Record ID" field of the button. I have a "display" column that does expand the hash variable correctly and will display the count of the associated records in table_3. If I hardcode the record id of one of the sub records then the button works as expected, but every row gives the same sub records.

I've also noticed that the title of the button is only placed on the first button in the subform.

Is there a better way to achieve what I want?

Thanks,

Cliff
admin
Site Admin
Posts: 2781
Joined: Mon Jun 15, 2009 2:23 am
nuBuilder Version: 4.5
Been thanked: 1 time

Re: Navigating from a subform row to the associated record

Unread post by admin »

Cliff,

I know this has been asked a few times, have you looked though the forum for answers?

Steven
cpenton
Posts: 2
Joined: Tue Apr 04, 2017 11:16 am

Re: Navigating from a subform row to the associated record

Unread post by cpenton »

Hi Steven,

Thanks for the nudge to look for an answer in the forum. I was only able to find a single thread that addressed what I was looking for:
http://forums.nubuilder.cloud/viewtopic.php?f=13&t=8521

However, when I tried this approach with my application it didn't work. Both nuRowPrefix(this) and nuRowNumber(this) returned undefined.

After looking at the source of the generated pages I worked out that the code bound to my button on the subform should contain:

Code: Select all

edit_row(this);
and the function in the containing form should be:

Code: Select all

function edit_row(btn){
    var id = $('#' + nuRowPrefix(btn) + '_nuPrimaryKey').val();
    nuOpenFormInFrame('58e22be7f0e9b20', id);
}
This works as expected.

I've now removed the button from the subform, as it annoyingly only puts the title on the first button, and put an onclick handler on all of the fields in the subform which takes me to the related edit screen. My next task is to work out how to update the parent form after I return from editing the record in the pop-up form. Any suggestions welcome :-)
admin
Site Admin
Posts: 2781
Joined: Mon Jun 15, 2009 2:23 am
nuBuilder Version: 4.5
Been thanked: 1 time

Re: Navigating from a subform row to the associated record

Unread post by admin »

cpenton,

I'm glad you had a look.

But this could be the thread, people coming after you may find helpful.

But to answer your last question you'll need to reload the page (nuReloadForm()).

Steven
Post Reply