I'm using an embedded view as a Tab Container type and I'm wondering whether the state of the tab (active, inactive, disabled) gets passed into the embedded view automatically in some property or if I have to do that myself.
I doubt that there is an automatic property, but I figure it's worth asking since the Flex Repeater, Table subview and other similar component features DO pass in properties like value
or rowIndex
automatically.
I already have an idea of how I'm going to do this manually and if I can confirm that this feature doesn't exist already, I'll share it here.
After some quick testing in the designer I didn't see any additional properties being passed into the viewParams. I did a system.perspective.print
of the self.params and just got the params I added.
You can really just pass in the currentTabIndex and use that
I'm not sure of the setup here.
Do you mean you have a an embedded view in a tab container's tab, or that you have an embedded view that contains a tab container ?
I see what you're asking. You can do what you want and more.
The structure of controls properties are derived from json. You can copy/paste the objects from the designer into a text editor to see the json structure and you can populate that json dynamically in a script transform on a binding on the base container (tabs) to dynamically build the structure of your tab container. Hard to explain.
You can populate all of this dynamically from a passed in parameter which could be an indirect tag binding to a UDT instance or you could pass a set of parameters and use an expression structure binding and a script transform (very flexible).
Test this on a blank tap container. I added a blank tab container and changed the tab type to "object" per the documentation. I populated the properties and the json for the "tabs" property of the tab container looks like this:
[
{
"text": "tab text",
"runWhileHidden": true,
"disabled": true
},
"tab 2",
"tab 3",
"tab 4",
"value"
]
I can derive this object structure dynamically from a binding using a script transform on the "tabs" property of the tab container like this:
tabs = [
{
"text": "tab text",
"runWhileHidden": True,
"disabled": True
},
"tab 2",
"tab 3",
"tab 4",
"value"
]
return tabs
You can inject whatever values into that structure that you want. It's SUPER flexible. You can pass information to the tab through parameters, message handlers, whatever makes sense for your layout. Then you just populate each object block using the variable data.
You're referring to the documentation and I'll post a link to anyone who stumbles into this in the future to help them understand it.
Yes, these are all good points and similar to how I ended up doing it BUT my question was if there was a built-in object or property that gets passed to each tab
, similar to how Table subviews get row
, rowIndex
, etc or how the Flex Repeater instances get an index
.
I ended up going with my backup plan - creating a tabs
custom property on the Tab Container component, then on the container's tabs
prop, I created an Expression structure binding with two properties: the currentTabIndex
and self.custom.tabs
(Tab Container custom properties.
After I had those two, I called a new library script function that returned the appropriate objects for me - here is some pseudo-code:
def get_container_tabs(tabs, currentTabIndex):
# check which tab is currently active
for i in range(len(tabs)):
if i == currentTabIndex:
tabs[i]["viewParams"]["state"] = "active"
else:
tabs[i]["viewParams"]["state"] = "inactive"
Doing it this was gives you a ton of flexibility - even just by adding an icon next to the text is already huge.
I don't think printing self.params
would show you default properties. For instance, on the Flex Repeater, unless you first go add an index
property on the view that's getting repeated, it won't get printed either even though that property exists in the background (?).
This is what I'm talking about, but for the Tab Container:
That looks like a good approach to me.
1 Like
Ah, that's my bad. I realize PropertyTreeScriptWrapper is the object type that is returned for self.params
which will only include the params you put in there. So, if I add index
to a components params tree in a flex repeater it works fine but does not show up otherwise. My apologies.