Page 1 of 1

Change tabpanel tabs sequence programmatically

PostPosted: Sat Apr 23, 2011 11:37 pm
by Mark Crichton
Hi

I am able to add a tab to a tabpanel programatically, but it always adds to the end. I would like to be able to place it in a specific sequence. eg after tab 2 and before existing tab 3
Even better, once placed, then be able to rearrange tabs based on their names.

function onAddPanel() {
// Add new tab to main panel
elements.tabs_mainPanel.addTab(forms.tst_Address,'testTab','Test Tab','tooltip for tst_address',null,'#000000','#feffe4')

//Set 'Home' tab to first tab ... was first
//Now add tab testTab in second position
//Set 'Details' tab to be 3rd tab ... was second tab
//Set 'People' tab to be 4th tab ... was 3rd tab

Any help greatly appreciated
thanks
Mark

Re: Change tabpanel tabs sequence programmatically

PostPosted: Sun Apr 24, 2011 12:38 am
by ROCLASI
Hi Mark,

The function addTab() has an index property at the end.
Code: Select all
addTab(form,[name],[tabText],[tooltip],[iconURL],[fg],[bg],[relatedfoundset/relationname],[index])

And for reshuffling the tabs you can use removeTabAt(index) together with the addTab() function.

Hope this helps.

Re: Change tabpanel tabs sequence programmatically

PostPosted: Sun Apr 24, 2011 1:20 am
by Mark Crichton
Hi Robert
Many thanks. I missed the really obvious. What I love about Servoy is that all the answeres to the questions I have had, have been reallly simple.
The removeTabAt(index) works perfectly as well. Servoy Rocks!

Re: Change tabpanel tabs sequence programmatically

PostPosted: Fri Oct 19, 2012 4:09 am
by maria.kyselova
Um.
Well, not sure if it's a bug.
I have two tabs on my form, I want to replace the form reference in the first one, so I remove it with .removeTabAt(1) and then add a tab with the new form with .addTab(...) passing it 1 as the last parameter, tabIndex.
Servoy sticks my tab in position 2 anyway.

Is the only way for me to swap the form in a tab - removing ALL tabs and then putting them back in preferred order? I'm not a fan of doing more work than I should have to :p

Cheers,
Maria

Re: Change tabpanel tabs sequence programmatically

PostPosted: Fri Oct 19, 2012 5:43 pm
by ljames
Hi Maria,

I've not done this myself, but I see that you've not gotten an immediate response so I figured I'd mention my thought. Is it possible the indexes start with 0 rather than 1? If so, passing 1 as the index would direct it to be the 2nd tab.

Re: Change tabpanel tabs sequence programmatically

PostPosted: Mon Oct 22, 2012 5:44 am
by maria.kyselova
ljames wrote:Hi Maria,

I've not done this myself, but I see that you've not gotten an immediate response so I figured I'd mention my thought. Is it possible the indexes start with 0 rather than 1? If so, passing 1 as the index would direct it to be the 2nd tab.


Hi James,

I'm fairly confident the indexes start with 1.
The problem holds if I have two tabs and add a third one passing the same index 1 and it still is added to the end of tabs which in case you suggested would have been index 2.
Thanks for responding though, hope we get some more attention now :)

Cheers,
Maria