Have data list load different data source based on block logic?

@tatiang
Hi I’m trying to on screen start have a data list load a certain data source based on the app setting.
Example user sets the grade level difficulty either 1,2,3,4,5 or 6.
When the screen starts I want the data list to load grade 1 data source. Currently the settings are in the side panel but trying to figure out through blocks to change this.


Different data sources
Screen Shot 2021-07-07 at 1.51.43 AM
Block logic if else statement it will check what grade level its set at then I’d have it load a data source in the data list.
Screen Shot 2021-07-07 at 1.51.59 AM

I asked a while back, is this possible today?

Instead of using different data sources, which would require a full set of rules for each source, just separate one data source into parts for each grade level.

For example, you might have grade level 1’s data start in row 1, grade level 2’s data start in row 11, grade level 3’s data start in row 21, etc. Then use a math formula (or a list of row #s) to determine which row to use for which grade level.

Or use Firebase which doesn’t have row & column constraints. You can set up the data however you like and you never have to “switch data sources.”

Also, when you have something like set picture to word1.png or word3.png or word5.png, you can also use math and a join text block to dynamically figure out the image name based on the value of the grade level. In my example, it would be set picture to join text [“word” & app variable grade level * 2 - 1 & “.png”]

2 Likes

There’s no way to use blocks to change what the data source is. You could write a bunch of logic for using a different source for each grade level (which would basically mean duplicating the parts that pull data from your datasources), but it might make more sense to have a column labeling … and Tatiang posted before I did. What he said. :slight_smile:

2 Likes

I dont know how to do this. In my experience a data lists loads everything from the data source with no code, once you set it here on the right side bar. Maybe you know more?

Sorry, I didn’t realize you were using a data viewer list (DVL) although you clearly included that as a screenshot earlier. You’re right, there’s no way to sync part of a data source to a DVL. And also no way to sync a different data source on the fly.

One way I’ve done this before is to create a DVL for each source and then hide all of the DVLs that aren’t needed. And then show each one and hide the others. But again, it’s a lot of code!

A more efficient way to do this is to use create or clone blocks to make your own DVL. Two notes about that: (1) there’s a learning curve in terms of understanding how to do that… it’s not that easy; (2) those features are only available in the older snap-to-place interface but not in the newer drag-and-drop interface.

1 Like

Thanks @tatiang I used the older snap-to-place interface.

If you know of a sample file that shows create or clone to make my own DVL I’d love to learn.

In the meantime I’ll try out the hide approach. :slight_smile:

This option worked for me “Yes!”

I put 6 DVL in the row and turned off visible in the settings panel so on start they are already invisible.
Then have an if else statement based on the user’s grade level show the certain DVL.

Thank you! @tatiang

2 Likes