Reusable Tab Menu Data Source

Hi,

I have a tab menu that I want to make into a reusable element. Is it possible to change the data source using properties so that on one page, I can retrieve the menu items from Options Set A, and on another page, I can retrieve the menu items from Options Set B?

If so, how do I do it?

Yes, you can do it.

Simply, add a flag to the reusable. You can name it Option Set to Use and set it as text. In my reusable below, I added a text to highlight in the header for example.

Then, in the header, wherever you need to change the data source, read that flag conditionally. That means if the flag Option Set to Use says A, then you use this one otherwise, use option set b. For example, a text is changing its color based on the value of that highlight property I set in the header (when the highlight is documents):
image

Then, when you use the reusable somewhere, all you need is to pass this value:
image

I hope that makes sense.

1 Like

Thanks. But can I use variable options sets and change the datasource based on what property that is active?

You should be able to change a lot of things conditionally, try and experiment :wink:

I tried this:

Two different types of options sets.

Default I have the Settings OS as my datasource and tried to add a condition with something like: When My element properties is … then data source …

But I couldn’t quite wrap my head around it… Any ideas?

Ok. I checked and you can’t change the type of content of RG conditionally, you can only change the data source. And when you think about it, it makes sense because you will do something based on clicking or current cell’s things, so if you change the data type conditionally, everything is broken.

I think what you should do is this:

  • Change the type of data of the RG to text.
  • Modify the reusable to accept a list of text as parameter.
  • Pass this parameter to the reusable wherever you are using by simply saying All Option Set:each item's Display.

See this example: Tests for Forum 14 | Bubble Editor where I pass two different option set values to a single reusable:

@Xtine It will be easier overall and better to work with option set rather than text. So, in my apps, what I would do is to create 1 option set. Then add an attribute that helps to signify what ‘group’ each option belongs to. Usually for me that is simple enough to have the attribute be of type yes/no…often times I might label that attribute as ‘Main’.

So one group of those options will have the attribute ‘Main’ as Yes, while the other group has attribute ‘Main’ as No.

Then when I want to change which values are shown, I get all options then use the :filtered operator and then use the constraint against the attribute main to say something like Main is Yes or Main is No to be able to switch between groups of options from the single option set.

If you have a setup with many pages, all of which have a need for different values, create a attribute of type text you call “Page Name” and add to that attribute for any particular option the Page Name exactly as you named it for which it would be shown on. Then you can craft a single expression for the datasource of RG to be all options with filtered operator attribute “Page Name” is current page name.

Additionally, if some of those options should be available for more than one page, I’d make the “Page Name” attribute a list of texts, and change my constraint on the filter for RG datasource to be ‘attribute Page Name contains current page name’

This way, I can continue to use Option Sets as an option set and not just text values, and do not need conditions on the RG to change data sources, and do not need to use Properties on the RE so no need to remember to set the value when I place the RE onto a page.

And I believe you are still likely working on this for BreadCrumbs, and since that I believe is on every page of your app, I’d be making that part of my Header, rather than a separate RE.

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.