Welcome to the nuBuilder Forums!
Register and log in to access exclusive forums and content available only to registered users.
Register and log in to access exclusive forums and content available only to registered users.
Link to record in subform on a tab
Link to record in subform on a tab
Hello all, I'm building a "to do" list. Right now there is a browse list that shows the Organization and to do item from a related table. The way the current form works is that when the user clicks on the browse record it opens the organization record and the user has to go to the to do tab and find the record in question in the sub form. The way I would like it to work is that clicking on the browse record, the to do item is opened in the subform. Is this possible?
-
- nuBuilder Team
- Posts: 4297
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 445 times
- Contact:
Re: Link to record in subform on a tab
Would it suffice if the to-do tab is opened and then the record in the subform focused/highlighted?treed wrote: The way I would like it to work is that clicking on the browse record, the to do item is opened in the subform. Is this possible?
-
- nuBuilder Team
- Posts: 4297
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 445 times
- Contact:
Re: Link to record in subform on a tab
Add the Primary Key column of the to-do item to the Browse form (column width 0 to hide it).
In the form's Custom Code add this JavaScript code.
Replace some values as indicated in the code
In the form's Custom Code add this JavaScript code.
Replace some values as indicated in the code
Code: Select all
function nuSelectBrowse(e) {
let pk = $('#' + e.target.id).attr('data-nu-primary-key');
let row = $('#' + e.target.id).attr('data-nu-row');
let pkColumn = '0'; // <------ Change: Column number of the to-do's primary key. 0 = first column, 1 = 2nd column etc.
window.pkToDo = $('#nucell_' + row + '_' + pkColumn).html();
nuForm(nuGetProperty('form_id'), pk, '', '', '0');
}
if (nuFormType() == 'edit') {
if (window.pkToDo !== undefined) {
nuSelectTab($('#nuTab1')[0]); // <------ Select the 2nd tab. nuTab2 would be the 3rd tab etc.
subFromHighlightRow('subform_id', window.pkToDo); // <------- Replace subform_id with the object Id of the subform
window.pkToDo = undefined;
}
}
function subFromHighlightRow(sfId, pk) {
var sf = nuSubformObject(sfId);
for (var i = 0; i < sf.rows.length; i++) {
if (sf.rows[i][0] == pk) {
var c = $('#' + sfId + nuPad3(i) + nuSubformObject(sfId).fields[1]);
c.css('color','#EC7063').focus();
return;
}
}
}
-
- nuBuilder Team
- Posts: 4297
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 445 times
- Contact:
Re: Link to record in subform on a tab
Hi, just wanted to follow up on this. Were you able to make it work?