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

**URL:** <https://community.thunkable.com/t/solved-use-buttons-to-swap-data-sources-in-data-viewer-list/1146005>\
**Category:** Questions about Thunkable X\
**Tags:** solved, data-viewer\
**Created:** [March 5, 2021, 3:11pm UTC](https://community.thunkable.com/t/solved-use-buttons-to-swap-data-sources-in-data-viewer-list/1146005 "2021-03-05T15:11:23Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![ozel1978](https://avatars.discourse-cdn.com/v4/letter/o/3ec8ea/32.png) [@ozel1978](https://community.thunkable.com/u/ozel1978)\
**Post date:** [March 5, 2021, 3:11pm UTC](https://community.thunkable.com/t/solved-use-buttons-to-swap-data-sources-in-data-viewer-list/1146005/1 "2021-03-05T15:11:23Z")

</div>

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](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/1/5/150674a0a0383f467cceda56e42369dd5b712464.png)

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [March 5, 2021, 6:37pm UTC](https://community.thunkable.com/t/solved-use-buttons-to-swap-data-sources-in-data-viewer-list/1146005/2 "2021-03-05T18:37:58Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ozel1978](https://avatars.discourse-cdn.com/v4/letter/o/3ec8ea/32.png) [@ozel1978](https://community.thunkable.com/u/ozel1978)\
**Post date:** [March 6, 2021, 4:12am UTC](https://community.thunkable.com/t/solved-use-buttons-to-swap-data-sources-in-data-viewer-list/1146005/3 "2021-03-06T04:12:27Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [March 6, 2021, 9:31am UTC](https://community.thunkable.com/t/solved-use-buttons-to-swap-data-sources-in-data-viewer-list/1146005/4 "2021-03-06T09:31:26Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![ozel1978](https://avatars.discourse-cdn.com/v4/letter/o/3ec8ea/32.png) [@ozel1978](https://community.thunkable.com/u/ozel1978)\
**Post date:** [March 6, 2021, 3:55pm UTC](https://community.thunkable.com/t/solved-use-buttons-to-swap-data-sources-in-data-viewer-list/1146005/5 "2021-03-06T15:55:57Z")

</div>

first step: create local data storage with necessary column.  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/e/a/ea5d10128554fb3b0da3e58547ba2fd7ef708b5d.png)

second step.  
something like this?  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/1/2/12eb07658a04f2bcbeb711303e490bc69357ad20.png)

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [March 6, 2021, 4:34pm UTC](https://community.thunkable.com/t/solved-use-buttons-to-swap-data-sources-in-data-viewer-list/1146005/6 "2021-03-06T16:34:09Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ozel1978](https://avatars.discourse-cdn.com/v4/letter/o/3ec8ea/32.png) [@ozel1978](https://community.thunkable.com/u/ozel1978)\
**Post date:** [March 7, 2021, 3:09pm UTC](https://community.thunkable.com/t/solved-use-buttons-to-swap-data-sources-in-data-viewer-list/1146005/7 "2021-03-07T15:09:25Z")

</div>

Muneer,

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

Thank you for your help.

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [March 8, 2021, 11:15am UTC](https://community.thunkable.com/t/solved-use-buttons-to-swap-data-sources-in-data-viewer-list/1146005/8 "2021-03-08T11:15:07Z")

</div>

@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](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/3/2/32f17e5b195e29bc333c643e4a88c4e503a3cc60.png)  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/6/a/6a726494f7e30136123b2a39c48d2ceb0acb1b6e.png)  
Click **Create New** and you should see  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/7/1/71f40d1524cb2db7954e0ace4e76a404acb58a66.png)  
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](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/f/9/f9e067aa1a7c8e97f161f2b38a3462ca2812b75a.png)  
The buttons simply call a function and pass a list of available records in the relevant table.

The function is this:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/d/9/d9a66547a98bb66ffae3e49101ab0a57ee5e617a.png)  
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.

---

<div class="post-metadata">

**Author:** ![ozel1978](https://avatars.discourse-cdn.com/v4/letter/o/3ec8ea/32.png) [@ozel1978](https://community.thunkable.com/u/ozel1978)\
**Post date:** [March 8, 2021, 12:52pm UTC](https://community.thunkable.com/t/solved-use-buttons-to-swap-data-sources-in-data-viewer-list/1146005/9 "2021-03-08T12:52:36Z")

</div>

Muneer,

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

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [March 8, 2021, 2:32pm UTC](https://community.thunkable.com/t/solved-use-buttons-to-swap-data-sources-in-data-viewer-list/1146005/10 "2021-03-08T14:32:31Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![maxdeca390i](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/maxdeca390i/32/99084_2.png) [@maxdeca390i](https://community.thunkable.com/u/maxdeca390i)\
**Post date:** [March 8, 2021, 8:38pm UTC](https://community.thunkable.com/t/solved-use-buttons-to-swap-data-sources-in-data-viewer-list/1146005/11 "2021-03-08T20:38:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [March 8, 2021, 8:51pm UTC](https://community.thunkable.com/t/solved-use-buttons-to-swap-data-sources-in-data-viewer-list/1146005/12 "2021-03-08T20:51:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![maxdeca390i](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/maxdeca390i/32/99084_2.png) [@maxdeca390i](https://community.thunkable.com/u/maxdeca390i)\
**Post date:** [March 8, 2021, 9:05pm UTC](https://community.thunkable.com/t/solved-use-buttons-to-swap-data-sources-in-data-viewer-list/1146005/13 "2021-03-08T21:05:11Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ozel1978](https://avatars.discourse-cdn.com/v4/letter/o/3ec8ea/32.png) [@ozel1978](https://community.thunkable.com/u/ozel1978)\
**Post date:** [March 9, 2021, 4:12am UTC](https://community.thunkable.com/t/solved-use-buttons-to-swap-data-sources-in-data-viewer-list/1146005/14 "2021-03-09T04:12:45Z")

</div>

muneer,

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

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/1/8/185fdf4c1e62f4b41e84b8df7c288842d9da5e20.png)

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [March 9, 2021, 4:24am UTC](https://community.thunkable.com/t/solved-use-buttons-to-swap-data-sources-in-data-viewer-list/1146005/15 "2021-03-09T04:24:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ozel1978](https://avatars.discourse-cdn.com/v4/letter/o/3ec8ea/32.png) [@ozel1978](https://community.thunkable.com/u/ozel1978)\
**Post date:** [March 9, 2021, 2:42pm UTC](https://community.thunkable.com/t/solved-use-buttons-to-swap-data-sources-in-data-viewer-list/1146005/16 "2021-03-09T14:42:09Z")

</div>

it look like variable to me and how create that?  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/8/f/8f5a041856ae9aa3f3038bf1f8187f55222f74a0.png)

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [March 9, 2021, 2:57pm UTC](https://community.thunkable.com/t/solved-use-buttons-to-swap-data-sources-in-data-viewer-list/1146005/17 "2021-03-09T14:57:00Z")

</div>

Lists are special kind of variables

 ![Screenshot_20210309_175541](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/9/f/9f4297408df42e1914778eeec0ea29c14bd15868.jpeg)

---

<div class="post-metadata">

**Author:** ![ozel1978](https://avatars.discourse-cdn.com/v4/letter/o/3ec8ea/32.png) [@ozel1978](https://community.thunkable.com/u/ozel1978)\
**Post date:** [March 9, 2021, 3:36pm UTC](https://community.thunkable.com/t/solved-use-buttons-to-swap-data-sources-in-data-viewer-list/1146005/18 "2021-03-09T15:36:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [March 9, 2021, 4:55pm UTC](https://community.thunkable.com/t/solved-use-buttons-to-swap-data-sources-in-data-viewer-list/1146005/19 "2021-03-09T16:55:50Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ozel1978](https://avatars.discourse-cdn.com/v4/letter/o/3ec8ea/32.png) [@ozel1978](https://community.thunkable.com/u/ozel1978)\
**Post date:** [March 10, 2021, 4:23am UTC](https://community.thunkable.com/t/solved-use-buttons-to-swap-data-sources-in-data-viewer-list/1146005/20 "2021-03-10T04:23:14Z")

</div>

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](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/1/a/1a24062542439f047a37b349da698b22dd3abd1e.png)

[Next page](https://community.thunkable.com/t/solved-use-buttons-to-swap-data-sources-in-data-viewer-list/1146005.md?page=2)
