Dear Servoy developer
I try to write code to get all subforms of an NG form. The form contains a bootstrapcomponents-tabpanel with three tabs.
How can I get the tabs of that JSWebComponent?
Thanks for any help!
Regards
Dear Servoy developer
I try to write code to get all subforms of an NG form. The form contains a bootstrapcomponents-tabpanel with three tabs.
How can I get the tabs of that JSWebComponent?
Thanks for any help!
Regards
Hi,
for the bootstrapcomponent Tabpanel you can access the tabs via the elements.tabpanel.tabs Array.
You can try this code snippet:
for (var i = 0; i < elements.tabpanel.tabs.length; i++) {
var tab = elements.tabpanel.getTabAt(i + 1);
application.output(tab.containedForm);
}
Regards,
Paolo
Thank you for the answer.
I only have a form name and would like to detect tabpanels and there tabs and the forms within the tabs. My code looks like:
var jsForm = solutionModel.getForm(formName);
var components = jsForm.getComponents();
for (var i in components) {
/** @type {JSComponent} */
var c = components[i];
if (c['typeName'] && c['typeName'] == 'bootstrapcomponents-tabpanel') {
// c is a tab panel. How do I get the tabs???
}
}
Any idea is appreciated a lot. Thank you.
Hi,
so you mean to read the tabs using solutionModel ?
In Web Components properties can be read via solution model using the getJSONProperty(propertyName).
e.g.
c.getJSONProperty("tabs")
You may need to get all elements as WebComponent rather than Components:
var components = jsForm.getWebComponents();
Dear Paolo
Oh, wow, it works!
I was sure I did try this before.
Thanks a lot.
Best regards
Birgit
Dear Paolo
Now I found the reason, why it did not work before: I tried to implement code to get subforms for a list of forms. But running the same code from Smart Client returns null for the tabs. Only from within a Client with application type NG, the tabs can be retrieved.
Is this expected behaviour? Not sure…
Thanks again and regards
Hi,
In Smart Client you can make use of the legacy TabPanel component ( your previous code would work then ).
The bootstrapcomponent-tabpanel is a WebComponent esclusive to NG; it would neither render in Smart Client.
They are in fact different components; therefore yes is expected behavior.
Regards,
Paolo
Hi Paolo
We currently deploy SC and NG clients for a customer. NG is new, though, until this application type runs stable, fallback is SC.
Now we have code, which will be executed in SC and NG. This code should find subforms for a selected menu (to find attributes and store access rights for the subforms). The result should be same, independent of the application type the code is executed in. For this, we iterate over all SC and NG forms, which are displayed for the selected menu. This is why we try to find subforms for an NG formname in SC. I hope, this is an understandable explanation?
Thank you for the responses and regards
@paronne Hi Paolo,
I know this thread is from a few years ago, but I am now trying to do the same thing as here, but for the purpose of getting all sub forms etc. from a main form that I have cloned using the solution model.
When I clone the main form, I am also cloning the forms used in the tabpanel & assigning them to the main cloned form tabpanel.
// replace real forms by clones
forms[cTblForm].elements.fc_filters.containedForm = forms[cFltrForm] ;
forms[cCloneFormName].elements.tabPanel.getTabAt(1).containedForm = forms[cTblForm] ;
[cTblForm is the name of the cloned original table form contained in the tab…]
but when I get back the name of the contained form in the main cloned form, it returns the design time form name, NOT the runtime assigned form name as expected!
How can I get the ‘clone’ form name, .i.e the one I assigned in the code above during runtime (I currently know exactly what it is, but I am trying to make generic code…)??
Thanks,
Rafi
p.s. your current [2025.6] embedded documentation is shockingly bad & is referring to JSTabPanel & other deprecated items, also in the Wiki
https://docs.servoy.com/reference/servoycore/dev-api/solutionmodel/jsform#getcomponents
Hi @rafig ,
i am not entirely sure i get your code flow; if you are mixing up solutionModel with runtime you may get the “wrong“ result.. i mean: you clone the form with solutionModel, fine, but then if you change the containeForm of tabs using runtime ( so elements.tabPanel.xx = yy ), this change exist only at runtime, does not exists in the blueprint of the cloned form, so you won’t be able to “read“ such change via solutionModel.
If you change containedForm at runtime, then you can read them only at “runtime“, so via elements.tabPanel.xxxx.
Hope this hint helps.
Cheers,
Paolo
Thanks Paolo, I will see if I can try another approach…