# Method addTab() doesn't work (in this situation)

**URL:** <https://forum.servoy.com/t/method-addtab-doesnt-work-in-this-situation/11636>\
**Category:** Classic Servoy\
**Created:** [January 19, 2010, 5:36pm UTC](https://forum.servoy.com/t/method-addtab-doesnt-work-in-this-situation/11636 "2010-01-19T17:36:42Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Robert\_Huber](https://avatars.discourse-cdn.com/v4/letter/r/da6949/32.png) [@Robert\_Huber](https://forum.servoy.com/u/Robert_Huber)\
**Post date:** [January 19, 2010, 5:36pm UTC](https://forum.servoy.com/t/method-addtab-doesnt-work-in-this-situation/11636/1 "2010-01-19T17:36:42Z")

</div>

Hi All

I load following 2 forms, both in table view, onto 2 different tabs. The form containing the 2 tabs is based on a dummy table with 1 record.

I use the following 2 statements to load the 2 forms:

```auto
elements.tabSelection.addTab(forms.PplPeriods, null, null, null, null, null, null);
		elements.tabDetail.addTab(forms.PplClasses, null, null, null, null, null, null, forms.PplPeriods.periods_accommodating_classes);

```

The 2 forms are loaded. By default, the top most record of the left side (i. e. elements.tabSelection.addTab(…)) is selected and the right side records are shown. So far so good.

But clicking any other record on the left side does not refresh the relationship to show the corresponding records on the right side. This is, I assume, because the the left tab is NOT based on the correct table (periods, in this example), but is dynamically loaded onto a generic main form with a dummy table.

Is there a way to refresh the relationship to get the corresponding records on the right side displayed?

It would reduce the numbers of (intermediate) forms a lot, if this would work.

Best regards, Robert

PS: Attached a screenshot to show the situation as described above looks like

 ![Screen shot 2010-01-19 at 18.35.20.png](https://canada1.discourse-cdn.com/flex010/uploads/servoy/original/2X/8/8490e9aff7a978f69615d519993a912f420c7703.png)

---

<div class="post-metadata">

**Author:** ![rgansevles](https://avatars.discourse-cdn.com/v4/letter/r/3d9bf3/32.png) [@rgansevles](https://forum.servoy.com/u/rgansevles)\
**Post date:** [January 19, 2010, 9:26pm UTC](https://forum.servoy.com/t/method-addtab-doesnt-work-in-this-situation/11636/2 "2010-01-19T21:26:42Z")

</div>

Robert,

If you add 2 related tabs on the form and the second tab’s relation is the first tab’s relation plus another relation 1 level deeper, the selection of the first tab synchronises with the second one.

For example, main form is based on no table.  
It contains 2 tabs, one based on g\_custid\_to\_orders, the second on g\_custid\_to\_orders.orders\_to\_orderdetails

The first tableview tab shows all orders of customer g\_custid.  
When selecting an order in this list, the order details of that order are shown in the second tab.

addTab command example:  
elements.tab2.addTab(forms.order\_details\_tabview,‘orderDetails’,‘Order Details’,null,null,‘#000000’,‘#BBCCEE’, ‘g\_custid\_to\_orders.orders\_to\_orderdetails’);

This is a new feature introduced in Servoy 5.0.

Rob

---

<div class="post-metadata">

**Author:** ![Robert\_Huber](https://avatars.discourse-cdn.com/v4/letter/r/da6949/32.png) [@Robert\_Huber](https://forum.servoy.com/u/Robert_Huber)\
**Post date:** [January 20, 2010, 7:20am UTC](https://forum.servoy.com/t/method-addtab-doesnt-work-in-this-situation/11636/3 "2010-01-20T07:20:54Z")

</div>

Hello Rob

This is very nice to hear, thank you! We will soon be on Servoy 5, currently still on Servoy 4, as the transition means still some work to do, before the switch can be done.  
My example is with Servoy 4.1.5, Mac OS X 10.6.2 and Java 1.6.

The left tab with the periods like HS 2009, FS 2009, … is directly on the table periods (containing the periods). The right tab is on the table classes. There is one relation from periods to classes called periods\_accommodating\_classes (starting from forms.PplPeriods)  
Now I would expect when selecting periods on the left side, the right side to show the classes to this period. This only works for the top most selection(which is done by Servoy by defautl when loading the tabs). Any further selection of a period shows still the classes to the top most period (in my example HS 2009), so it means this doesn’t work. Will it work in Servoy 5?

Best regards, Robert

---

<div class="post-metadata">

**Author:** ![rgansevles](https://avatars.discourse-cdn.com/v4/letter/r/3d9bf3/32.png) [@rgansevles](https://forum.servoy.com/u/rgansevles)\
**Post date:** [January 20, 2010, 8:57am UTC](https://forum.servoy.com/t/method-addtab-doesnt-work-in-this-situation/11636/4 "2010-01-20T08:57:54Z")

</div>

> Robert Huber:  
> Will it work in Servoy 5?

Yes, but don’t hesitate to play around with this, especially with the new 5.1 beta.

Rob

---

<div class="post-metadata">

**Author:** ![Robert\_Huber](https://avatars.discourse-cdn.com/v4/letter/r/da6949/32.png) [@Robert\_Huber](https://forum.servoy.com/u/Robert_Huber)\
**Post date:** [January 20, 2010, 9:40am UTC](https://forum.servoy.com/t/method-addtab-doesnt-work-in-this-situation/11636/5 "2010-01-20T09:40:36Z")

</div>

Rob, very nice!  
And it’s correct that it doesn’t work in Servoy 4.1.5?

Best regards, Robert

> rgansevles:
> 
> > Robert Huber:  
> > Will it work in Servoy 5?
> 
> Yes, but don’t hesitate to play around with this, especially with the new 5.1 beta.
> 
> Rob

---

<div class="post-metadata">

**Author:** ![erdione](https://avatars.discourse-cdn.com/v4/letter/e/e9a140/32.png) [@erdione](https://forum.servoy.com/u/erdione)\
**Post date:** [January 20, 2010, 10:06am UTC](https://forum.servoy.com/t/method-addtab-doesnt-work-in-this-situation/11636/6 "2010-01-20T10:06:58Z")

</div>

It could work in 4.1.5

In servoy 4 or 5 when you have a relation you must have a starting point for you relation leading to the related foundset that will be displayed.

- for example if your dummy form is based on periods, it’s very easy to display a related form in a tabpanel with this piece of code

```auto
elements.tabDetail.addTab(forms.PplClasses, null, null, null, null, null, null, 'periods_accommodating_classes');

```

- if you have a global relation for example mycurrentperiods\_accommodating\_classes (from a global var (id of the current period) to period id of the class ) you can put a related tabpanel everywhere, and you only need to update your global var

these are the basic servoy relation concepts.

in your scenario, your question must be what could be the link between my two different tabpanels?

you could find a link with for example a global mycurrentperiods that could be updated onselectedrecord in your period form and a gloabl relation

Hope that help you

---

<div class="post-metadata">

**Author:** ![Robert\_Huber](https://avatars.discourse-cdn.com/v4/letter/r/da6949/32.png) [@Robert\_Huber](https://forum.servoy.com/u/Robert_Huber)\
**Post date:** [January 20, 2010, 10:50am UTC](https://forum.servoy.com/t/method-addtab-doesnt-work-in-this-situation/11636/7 "2010-01-20T10:50:38Z")

</div>

Bonjour Fabrice

Thanks for the suggestions. What I tried to mention is that in the addTab() method everything is already defined. The first form (in my example forms.PplClasses) is the related form, the form on the m-side of the relation. And it “knows” on which table it is based.  
The form of the relation (the last parameter of addTab()) also “knows” on which table it is based. The relation is also defined. The last parameter reads in my example: forms.PplPeriods.periods\_accommodating\_classes. This is always the 1-side of the relation.

So everything necessary is defined, but it does’t work in Servoy 4. But it’s not a problem for us and we are very happy when it works in Servoy 5.

Merci, Robert

> erdione:  
> It could work in 4.1.5
> 
> In servoy 4 or 5 when you have a relation you must have a starting point for you relation leading to the related foundset that will be displayed.
> 
> - for example if your dummy form is based on periods, it’s very easy to display a related form in a tabpanel with this piece of code
> 
> ```auto
> elements.tabDetail.addTab(forms.PplClasses, null, null, null, null, null, null, 'periods_accommodating_classes');
> 
> ```
> 
> - if you have a global relation for example mycurrentperiods\_accommodating\_classes (from a global var (id of the current period) to period id of the class ) you can put a related tabpanel everywhere, and you only need to update your global var
> 
> these are the basic servoy relation concepts.
> 
> in your scenario, your question must be what could be the link between my two different tabpanels?
> 
> you could find a link with for example a global mycurrentperiods that could be updated onselectedrecord in your period form and a gloabl relation
> 
> Hope that help you

---

<div class="post-metadata">

**Author:** ![Robert\_Huber](https://avatars.discourse-cdn.com/v4/letter/r/da6949/32.png) [@Robert\_Huber](https://forum.servoy.com/u/Robert_Huber)\
**Post date:** [January 25, 2010, 11:08am UTC](https://forum.servoy.com/t/method-addtab-doesnt-work-in-this-situation/11636/8 "2010-01-25T11:08:50Z")

</div>

Hi Rob

I am at Servoy 5 now, but unfortunatly, the above described implementation doesn’t work either in Servoy 5.0.1.

Any idea?

Regards, Robert

> rgansevles:
> 
> > Robert Huber:  
> > Will it work in Servoy 5?
> 
> Yes, but don’t hesitate to play around with this, especially with the new 5.1 beta.
> 
> Rob

---

<div class="post-metadata">

**Author:** ![rgansevles](https://avatars.discourse-cdn.com/v4/letter/r/3d9bf3/32.png) [@rgansevles](https://forum.servoy.com/u/rgansevles)\
**Post date:** [February 2, 2010, 12:36pm UTC](https://forum.servoy.com/t/method-addtab-doesnt-work-in-this-situation/11636/9 "2010-02-02T12:36:01Z")

</div>

Robert,

Attached is a small example that does what I mean.  
When you change the selection in the left tab (orders) the right tab changes (ordere details)

Rob

[orders\_sample.servoy](https://forum.servoy.com/uploads/short-url/7FnD7OiggnexXy80VgVYGiM1dmu.servoy) (43.3 KB)

---

<div class="post-metadata">

**Author:** ![Robert\_Huber](https://avatars.discourse-cdn.com/v4/letter/r/da6949/32.png) [@Robert\_Huber](https://forum.servoy.com/u/Robert_Huber)\
**Post date:** [February 2, 2010, 6:14pm UTC](https://forum.servoy.com/t/method-addtab-doesnt-work-in-this-situation/11636/10 "2010-02-02T18:14:39Z")

</div>

Hi Rob

May be I am missing something, but this example shows a static situation, not the dynamic one I described. There is no addTab() command, or at least I didn’t find it.  
In your example, the 2 forms orders and order\_details should be loaded dynamically to their tabless panels tabs\_80 and tabs\_190 with elements.addTab().  
The order\_details should be loaded with something like: elements.tabs\_190.addTab(forms.order\_details, null, null, null, null, null, null, forms.orders.orders\_to\_order\_details);  
That is the situation I tried to describe which does not work.

Could you have a look again, please.

Regards, Robert

> rgansevles:  
> Robert,
> 
> Attached is a small example that does what I mean.  
> When you change the selection in the left tab (orders) the right tab changes (ordere details)
> 
> Rob
