Is it possible to hide a tab in a tabpanel? I’d like to make the show or no-show of one relationless tab dependent on a relationship. The tabpanel itself already has three other tabs which should appear regardless.
Is this possible? The setup for such a condition isn’t obvious.
Well, under elements the tabpanel should have setTabEnabled(number index, boolean enabled).
So if you know (or can otherwise determine) the tab’s index and can construct an expression to calculate if it should be displayed then you may have enough for an onShow(?) method running on the enclosing form.
Use setTabEnabled to enable or disable the tab and hook it up to the onRecordSelection event so it is triggered every time a record is selected. Do NOT use a calc for this!!
jaleman:
Use setTabEnabled to enable or disable the tab and hook it up to the onRecordSelection event so it is triggered every time a record is selected. Do NOT use a calc for this!!
Excellent! However I’m having problems with syntax. In the following, when f_correspond tests for 1 or 0, the tab appears both ways. Obviously missing something. The target tab is the fourth from the left.
// shows or hides Correspondence tab depending on setting on secFeatures
application.output('crMain.onRecordSelection f_correspond = ' + gsevid$to_sev.f_correspond);
if ( gsevid$to_sev.f_correspond == 1 )
{
elements.tabs_70.setTabEnabled(4,true);
}
else
{
elements.tabs_70.setTabEnabled(4,false);
}
The setTabEnabled () function does what it says in that it either enables or disables the tab - which means that you can either click it or not !
So your code probably works but there is no visual cue that it has worked !
Whay not combine it with: setTabColorAt () to disable it and give it a distinct ‘not active’ colour so that the user knows before he/shge clicks on it !?
Missed that command as it was not in my help files !
Two points:
Does this command also then allow you to return the tab as was or do you need to remember what the tab was in order to restore it ?
Where can I get an up to date help version for my Servoy application ?
Cheers
Harry
It’s correct that it is not in help as it is new to 2.2. Helpfiles are generally not released in beta. However there are samples in the method editor and it has also been discussed earlier on the forum (I think). The function is pretty straightforward: it removes the tab. You can also add tabs to a tabpanel. It allows you to build a reversed navigation form: You always stay on one form that has nav stuf on all sides with in the middle one tabless tabpanel on which you keep throwing forms based on where one wants to navigate too. You can even make your nav entirely configurable using this approach.
For such a navigation scheme to work there needs to be syntax to restore a tab. In my experiments I’ve discovered once a tab is hidden it won’t come back until the solution is restarted. I’m looking for a toggle effect.
// shows or hides Correspondence tab depending on setting on secFeatures
if ( gsevid$to_sev.f_correspond == 1 )
{
// shows tab
application.output('f_correspond == 1');
// unknown command to restore display of the 4th tab
}
else
{
// hides tab
application.output('f_correspond !== 1');
elements.tabs_70.removeTabAt(4);
}
jaleman:
It doesn’t hide the tab, it removes the tab. If you want it back add it back, scan through the list of stuff on the tabpanel and you’ll see!
The removeTabAt(4) has the effect of denying the tab to the user. It would be useful to that end user in some circumstances to bring the tab back.
This thread began looking for a way to hide a tab (deny the user awareness of and access to the tab). In much the same way as hiding a button, there are occasions it would be useful to reveal and restore access to the tab.
“Scan through the list of stuff on the tabpanel”. How does one do that programmatically? It’s late at night and I’m being dense.
I believe that Jan just meant for you to scan through the function options which you have for a tabpanel object and see which combination of those properties best fits your requirements.
You can see them in designer mode under the navigator tree:
Application → Forms → ‘formName’ → Elements → ‘tabPanelName’
So you select the tabpanel element which you have added to your form and then all the available functions for that tabpanel will be displayed including those previously mentioned in this thread.
Also look through the help files under:
Methods → Forms → Form Elements
The same functions list is in here with added information.
Have gone through them all. It would appear once you’ve run removeTabAt(integer) there is no inverse command which restores a tab. If true, an odd omission.
Morley:
Have gone through them all. It would appear once you’ve run removeTabAt(integer) there is no inverse command which restores a tab. If true, an odd omission.
Morley, if I suggest that you should have a look (as I did in an earlier post), you might take that as a hint that there is a function that does the reverse of remove. How about add? Wouldn’t it make sense if you could remove tabs that you could also add them?
jaleman:
Morley, if I suggest that you should have a look (as I did in an earlier post), you might take that as a hint that there is a function that does the reverse of remove. How about add? Wouldn’t it make sense if you could remove tabs that you could also add them?
Just in case you still can’t find it:
on a tab click on the first function: addTab
check the syntax and move sample
Thrown off the scent by the sample code from addTab:
Add a relationless form as a tab
I’ve already created the tab. Plus the tab I want to restore has a relationship. Just want to hide and reveal it. Sorry for the difficulties. I’ll work around the problem.
Morley:
I’ve already created the tab. Plus the tab I want to restore has a relationship. Just want to hide and reveal it. Sorry for the difficulties. I’ll work around the problem.
You already have a tabpanel. You removed a tab and now want the tab back. The tab has to be relationless but then in your first post you said:
Morley:
I’d like to make the show or no-show of one relationless tab .