[Solved] Use buttons to swap data sources in data viewer list

Hi All,

how to set from button to one data viewer list as per screen shoot below.

from block provided, i have no idea how to do that.

image

1 Like

Can explain further. What exactly do you want when button “+ sayur” for example is clicked?

muneer,

plan when i click button sayur my database from that button will populate at data viewer list and other buttons also have their own database and will populate at same data viewer list. i need only one data viewer list. i can do multiple for data viewer list but i think is not efficient.

1 Like

That is easy.

Create a Local Data Storage with the columns necessary and connect that local table with the DVL (Data Viewer List).

Now, when the user clicks on any button, you will delete all data in the local table and fill it with the data from your database that corresponds to that button.

Happy Thunking!

first step: create local data storage with necessary column.
image

second step.
something like this?
image

1 Like

I would create a Local Data Storage like showSelected and then bind it to the data viewer.

Then when clicking the button “sayur” you will delete all rows in the table showSelected then you will access your original database containing “sayur” to read the records and add the rows containing the column you want to show to the table showSelected.

When clicking another button such as “sea” the app will just delete all rows in showSelected and then access the database with the original records for table “sea” and add the rows with the column you want to show to the table showSelected.

The same for other keys.

Muneer,

if i can have sample in block that would be appreciated. when you are free.

Thank you for your help.

1 Like

@ozel1978
I made a quick screen to demonstrate the idea. Please note that I made it as Local Data Storage but the same applies to Airtable. When you add Airtable tables in your project please use the Data Sources + sign not the Airtable component.
image
image
Click Create New and you should see
image
From here you can choose the Airtable. I used the Create your own table for simplicity because Airtable tables will require Keys and will not be accessed by others without the keys.

However, when tables are created this way, they all share the same blocks and you will just need to reconnect your tables and reference them in the code blocks.

The Demo
I created a DVL (Data Viewer List) and bound it with the table showSelected.
I created three buttons and in the block screen I did this
image
The buttons simply call a function and pass a list of available records in the relevant table.

The function is this:


This function does it all.
It first clear the showSelected table then checks the list of available records actually has at least one record to loop through the list and add the values to the showSelected table which is connected to the DVL and the results will automatically shows in the DVL.

Hope this makes it clear.

2 Likes

Muneer,

thank you for your block, i will let you know after i am testing this block

1 Like

Take you time. This is the project
https://x.thunkable.com/projectPage/603760b93661f50013276bc8

1 Like

Grazie muneer il suo progetto è molto interessante,
era una cosa che volevo fare da un poco di tempo ma purtroppo essendo un autodidatta non ero riuscito.
Grazie

1 Like

You are welcome. If you have any other questions, just ask it in here and there are many qualified members who can help.

1 Like

grazie siete molto gentili,
sono un principiante per ora mi voglio studiare bene il suo blocco e capirlo bene

1 Like

muneer,

what wrong with with my block? i do exactly as you do but nothing happen

1 Like

In the function you should check the length of fromlist. You are checking app variable listfromtable which is not what you want.

it look like variable to me and how create that?
image

1 Like

Lists are special kind of variables

yeah my question is from where to get the block “fromlist”?

1 Like

In Thunkable there are two ways to select a variable.

  • From the variables drawer, select the required variable from the ones listed and connect it to the appropriate block.

  • From the variable that is currently in the blocks, click on it and the drop-down menu will appear listing all variables, select the one you want.

Hope this is clear.

1 Like

Muneer,

working fine for now thank you for your help.

further step i want to swipe left and place text to label. normal block this should working fine but this time it send empty text. any suggesting?

image