Dynamically loading a related form

Hi All

I try to load a form and the related foundset (as described in Servoy Developer Reference Guide). The cmd looks like this:

forms.ScoRatingsAndHeader.elements.tabDetail.addTab(forms.ScoRatings, null, null, null, “#000000”, “#BBCCEE”, forms.ScoRatingsAndHeader.assessments_or_scored_with_ratings.forms.ScoRatings);

where forms.ScoRatingsAndHeader is based on table assessments and forms.ScoRatings is based on table ratings (relationship is 1:m between assessments and ratings)

I get error in attachment 1.

Using

forms.ScoRatingsAndHeader.elements.tabDetail.addTab(forms.ScoRatings, null, null, null, “#000000”, “#BBCCEE”, forms.ScoRatingsAndHeader.assessments_or_scored_with_ratings.forms);

leads to error in attachment2.

Just loading the unrelated forms works. The cmd then is

forms.ScoRatingsAndHeader.elements.tabDetail.addTab(forms.ScoRatings, null, null, null, “#000000”, “#BBCCEE”);

Putting the related form “hard wired” on the tabDetail pane works.

I am not sure if I am doing it wrong or if it’s a bug. Anyone using this?

Best regards, Robert

Hi Robert

Have you tried using ```
forms.WEBform.elements.webBody.removeAllTabs()

forms.ScoRatingsAndHeader.elements.tabDetail.addTab(forms.ScoRatings, null, null, null, "#000000", "#BBCCEE", forms.ScoRatingsAndHeader.assessments_or_scored_with_ratings.forms.ScoRatings); 
```The last argument is not a foundset if I read this correct...

forms.ScoRatingsAndHeader.elements.tabDetail.addTab(forms.ScoRatings, null, null, null, “#000000”, “#BBCCEE”, forms.ScoRatingsAndHeader.assessments_or_scored_with_ratings.forms);


The same here

Hi Graham

What would these statements do?

Thanks, Robert

PS: Please see my reply below, problem is solved!

grahamg:
Hi Robert

Have you tried using ```
forms.WEBform.elements.webBody.removeAllTabs()

Good to hear the problem was solved.

As I understand it …removeAllTabs is just good housekeeping to ensure that where you are dynamically adding & removing Tab panels there are no conflicting Tabs left over from previous code.

Picked this up from Maarten B who showed it was possible to have a solution running on a single Main Form.

Hi Marcel

Thanks for replying. I found the problem! With no optional parameters the position of the parameters seems not so critical, BUT when using the optional parameter(s), it is.

A related tab panel perfectly works with that stmt:

forms.ScoRatingsAndHeader.elements.tabDetail.addTab(forms.ScoRatings, null, null, null, null, “#000000”, “#BBCCEE”, forms.ScoRatingsAndHeader.assessments_or_scored_with_ratings);

The “only” difference is the insertion of another null value and therefor the relationship is (now correctly) at the 8th position!

I had quite many wrong statements which work without a problem. But corrected them all of course, now that I realized that actually there are wrong.

Best regards, Robert

IT2Be:

forms.ScoRatingsAndHeader.elements.tabDetail.addTab(forms.ScoRatings, null, null, null, "#000000", "#BBCCEE", forms.ScoRatingsAndHeader.assessments_or_scored_with_ratings.forms.ScoRatings); 
```The last argument is not a foundset if I read this correct...


forms.ScoRatingsAndHeader.elements.tabDetail.addTab(forms.ScoRatings, null, null, null, “#000000”, “#BBCCEE”, forms.ScoRatingsAndHeader.assessments_or_scored_with_ratings.forms);



The same here

Hi Graham

Sorry, don’t know what I read :-( Yes, I also use the removeAllTabs, simply because it wouldn’t work without it.
Can you load a tab into a tabless tab without using removeAllTabs before the addTab stmt?

Best regards, Robert

PS: We also build our school admin and info system app with dynamically loading tabs into the main (top) forms structure, which is basically a 3 column structure. It’s built after iTunes (left column is the “menu” (dbTreeView), middle is a “selection” column and the right (wide) column contains the “detail”. Sometimes the detail is a forms, sometimes a list view. Sometimes the detail column is further divided into 2 columns.
I think loading forms into a basic structure is quite elegant and gives much more flexibility - also for applying size changes.

grahamg:
Good to hear the problem was solved.

As I understand it …removeAllTabs is just good housekeeping to ensure that where you are dynamically adding & removing Tab panels there are no conflicting Tabs left over from previous code.

Picked this up from Maarten B who showed it was possible to have a solution running on a single Main Form.

Hello All

What is the (best) way to sort a dynamically loaded related form? I tried using this:

	forms.ScoMarksOrRatingsAndHeader.elements.tabDetail.removeAllTabs();
	forms.ScoMarksOrRatingsAndHeader.elements.tabDetail.addTab(forms.ScoMarks, null, null, null, null, "#000000", "#BBCCEE", assessments_scored_with_marks.sort("value desc"));

but then, the related data is not displayed any more at all :-(

What would another possibility be?

Any ideas?

Thanks and best regards, Robert

Robert,

The sort method works on the foundset, but does not return the foundset.
So, the last argument to addTab is actually null.
You will have to sort before or after the call to addTab.

Rob

Hi Robert

Thanks for the hint - I just realized I have to look for the return value of sort, which is void, so as you say, the argument is null, therefor the m-side form (tabless tab panel) not shown.

Thanks for your help, regards, Robert

rgansevles:
Robert,

The sort method works on the foundset, but does not return the foundset.
So, the last argument to addTab is actually null.
You will have to sort before or after the call to addTab.

Rob