Navigating from a subform row to the associated record

Navigating from a subform row to the associated record

Postby cpenton » Tue Apr 04, 2017 7:03 pm

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
cpenton
 
Posts: 2
Joined: Tue Apr 04, 2017 6:46 pm

Re: Navigating from a subform row to the associated record

Postby admin » Sat Apr 08, 2017 4:29 pm

Cliff,

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

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

Re: Navigating from a subform row to the associated record

Postby cpenton » Tue Apr 11, 2017 2:17 am

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.com/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 :-)
cpenton
 
Posts: 2
Joined: Tue Apr 04, 2017 6:46 pm

Re: Navigating from a subform row to the associated record

Postby admin » Wed Apr 12, 2017 6:29 am

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


Return to General