Change tabpanel tabs sequence programmatically

Questions and answers for designing and implementing forms in Servoy

Change tabpanel tabs sequence programmatically

Postby Mark Crichton » Sat Apr 23, 2011 11:37 pm

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
Mark Crichton
DataWise Ltd - New Zealand
http://www.datawise.co.nz
User avatar
Mark Crichton
 
Posts: 109
Joined: Mon Jan 24, 2011 10:01 am
Location: Auckland, New Zealand

Re: Change tabpanel tabs sequence programmatically

Postby ROCLASI » Sun Apr 24, 2011 12:38 am

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.
Robert Ivens
ROCLASI Software Solutions / JBS Group, Partner
SAN Developer / Servoy Valued Professional / Servoy Certified Developer
Twitter: @roclasi / @servoyforge
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5276
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

Re: Change tabpanel tabs sequence programmatically

Postby Mark Crichton » Sun Apr 24, 2011 1:20 am

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!
Mark Crichton
DataWise Ltd - New Zealand
http://www.datawise.co.nz
User avatar
Mark Crichton
 
Posts: 109
Joined: Mon Jan 24, 2011 10:01 am
Location: Auckland, New Zealand

Re: Change tabpanel tabs sequence programmatically

Postby maria.kyselova » Fri Oct 19, 2012 4:09 am

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
Cheers,
Maria
maria.kyselova
 
Posts: 172
Joined: Thu Aug 09, 2012 12:56 am

Re: Change tabpanel tabs sequence programmatically

Postby ljames » Fri Oct 19, 2012 5:43 pm

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.
ljames
 
Posts: 12
Joined: Fri Sep 14, 2012 6:51 pm

Re: Change tabpanel tabs sequence programmatically

Postby maria.kyselova » Mon Oct 22, 2012 5:44 am

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
Cheers,
Maria
maria.kyselova
 
Posts: 172
Joined: Thu Aug 09, 2012 12:56 am


Return to Forms

Who is online

Users browsing this forum: No registered users and 5 guests

cron