Setting focus on tab control when using Nested Tabsets

Post any questions you have about using the Verj.io Studio, including client and server-side programming with Javascript or FPL, and integration with databases, web services etc.

Moderators: Jon, Steve, Ian, Dave

Segi
Ebase User
Posts: 649
Joined: Mon Dec 09, 2013 6:37 pm

Setting focus on tab control when using Nested Tabsets

#1

Postby Segi » Wed May 06, 2015 11:15 pm

I am using nested TabSets that are structured this way:

PARENT_TABSET (Toplevel TabSet)
---------->MANAGE_TAB (1st tab of PARENT_TABSET)
--------------->MANAGE_TABSET (TabSet that is the only child control of MANAGE_TAB)
--------------------->12 tabs that belong to MANAGE_TABSET
---------->VIEW_TAB (2nd tab of PARENT_TABSET)
--------------->VIEW_TABSET (Tabset that is the only child control of VIEW_TABSET)
--------------------->3 tabs that belong to VIEW_TABSET
---------->MISC_TAB (3rd tab of PARENT_TABSET)
--------------->MISC_TABSET (Tabset that is the only child of MISC_TABSET)
--------------------->2 tabs that belong to MISC_TABSET

I have a field called JUMP_TO_TAB that is a dropdown that I have populated with the tab header text of all the individual tabs for each tab set (17 items in the dropdown total which is 12+3+2). I want to be able to select an item from the dropdown and select that tab so it has the focus.

This is my code so far.

Code: Select all

for each (var currentParentTabset in parent_tabset) {
     var child_tabset=controls.getControl(currentParentTabset.elementName).childControls;

     for each (var currentChildTabset in child_tabset) {
     	    var child_child_tabset=controls.getControl(currentChildTabset.elementName).childControls;

     	    for each (var currentChildChildTabset in child_child_tabset) {
     	         if (currentChildChildTabset.elementName == fields.JUMP_TO_TAB.value) {
     	              controls.getControl(currentChildTabset.elementName).selected=currentChildChildTabset.elementName;
     	         }
     	    }
     }
}

This does work when I select a value in the dropdown for a tab that is in the tabset that currently has the focus is already. However if I select a value in the dropdown for a tab that is in a different tabset that does not current;y have the focus, nothing happens which I'm not surprised about since it doesn't have the focus.

I cannot figure out how to make this work correctly. Do I need to set the selected on PARENT_TABSET then one of its 3 children tabsets first ?

I did try setting the selected tab of PARENT_TABSET first but this causes a weird problem where it is like I specified a non-existing tab to set the focus on because it is as if no tab is selected.
0 x

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

#2

Postby Jon » Thu May 07, 2015 9:40 am

You could do something like this. This is not very sophisticated but seems to work. It assumes that you always have two levels of nested tabs with no extra controls intervening, that the lowest level tab selection names are unique, and that the selection always applies to the lowest level.

Code: Select all

// get tab selection
var sel = "xxxxxx";

// get the Tab Control for this selection
var tabCtrl = findTabControl(sel);
if (tabCtrl)
{
	// set selection on parent tabset control
	tabCtrl.parentControl.selected = sel;

	// set selection on tabset's parent tabset
	var parentTab = tabCtrl.parentControl.parentControl;
	if (parentTab && parentTab.elementType == "Tab Control")
	{
		var parentSel = parentTab.itemName;
		parentTab.parentControl.selected = parentSel;
	}
}

function findTabControl(sel)
{
	for each (var ctrl in form.currentPage.allControls)
	{
		if (ctrl.elementType == "Tab Control")
		{
			if (ctrl.itemName == sel)
			{
				return ctrl
			}
		}
	}
}
0 x

Segi
Ebase User
Posts: 649
Joined: Mon Dec 09, 2013 6:37 pm

#3

Postby Segi » Thu May 07, 2015 3:33 pm

Thank you,

Your code worked perfectly and is simpler than mine.
0 x


Who is online

Users browsing this forum: No registered users and 14 guests