Datalist with conditions

Hi,
I’m developing an App using a Data viewer grid and a data viewer list.
In particular, I would like to select an item from a Datagrid that use a table as datasource and then show a data viewer list with datasource in another table, showing only elements that are in the second table but linked to the first table item selected.
Is it possible?
Example:
Table1:
James
Mike
Luke
Table2:
*Mike football
*Mike pingpong
*James soccer
*Mike jogging

If i slect Mike from datagrid, I will show a list with football,pingpong and jogging
If I select James, a list with only soccer
If I select Luke, no list at all.

It is a simple thing to do using queries, but how to do with Dataviewer list and grid?
Dataviewer list allow to select a datasource but doesn’t allow to filter results. Am I right?
Is there a way to do what i need?
Summing up: Is there a way to associate data to datalist or datagrid programmatically?
Thank you

Check these threads

Nothing in those threads about dataviewer list and grid component.
They seems all about how to display data, but I need how to retrieve data.
It seems like I have to retrieve all the table and then filter the results, without possibility to retrieve only data i need.
I hope it’s not so.

Thought you already have the answer in the first post? I’m afraid you may need to maintain two data source, eg. Airtable would be easiest to me. One is the global data you can contain. the other is the data table you point to with data view /list. Programmatically, you take your global data, filter/choose the items you want and update the dataview/list associated table…

btw what type of filtering sorting you need to do?

I would like to insert in a Dataviewerlist component ONLY SOME records from an airtable table.
But to do so I have 2 problem:

  1. I found no way to insert programmatically data in a Dataviewerlist, I can set it only in “Design” view of the screen
  2. I would like to query the main table in Airtable getting only data I need and not get all the table and then filter it using blocks.

At the moment it seems to me that the only solution is:
1)Create a view like a list manually
2)Get the entire table from airtable (being an event calendar it can become a big table and slow down the whole app) and filter it manually and then show results in the manually created list

Is this really the only solution?

  1. Associate the dataviewer list/grid to an airtable from the design. Use Airtable API blocks to add items or delete items. Next time the app is refreshed or restarted, the dataviewer list/grid will reflect the new addition or edits.

  2. You can actually only “get” a selected column to find the “index” you want, then use it to point to the row and download the selected record. No need download whole table. If you need more advanced features like sorting before download or download specific ranges, You may try Airtable native REST API. Accessible using web API blocks.(can do “sort by specific column” or “filter by formula”) ,

  1. Maybe I write it wrong. I meant SHOW data in Dataviewerlist. There is no way to, for example, build some records programmatically and then show them in a dataviewerlist using blocks
  2. I need to populate the dataviewerlist with filtered data. REST API can be a solution, but can you post an example on how to use it with airtable?
    But, at the end, the result of the web API could be not be showed on a dataviewerlist, right?

I meant to say, use an airtable database to SHOW the data as a dataviewerlist in your app. Then PROGRAMMATICALLY use airtable blocks to build and add records to that airtable database. By doing so, any restart to your screen will show the dataview list with the updated database. I just did it with a minimum working example…

Go to your airtable interface, find API documentation. There you will find specific example of how to access your table data. including the property of using “filterByFormula”. It may be daunting at first, but once you get the main methods, then you will be able to do a lot of powerful things.(I personally used the “sort” feature, it allowed me to download my table sorted to the column I need)

Thank you so much.
I’m working on it.
Now I’m able to retrieve only data I need, And I have to work on How to display them
I would like to use a dataviewer list but it’s impossible so I have to create a list using this kind of response:
{
“records”: [
{
“id”: “recgPaS5xkdop0jah”,
“fields”: {
“Name”: “Ai Tamerici”
},
“createdTime”: “2020-08-07T13:16:03.000Z”
},
{
“id”: “recXmfsVBU0SlWlQZ”,
“fields”: {
“Name”: “Marinamore”
},
“createdTime”: “2020-08-07T13:16:03.000Z”
},
{
“id”: “rec8sHGXZy34yI95F”,
“fields”: {
“Name”: “La Dolce vita”
},
“createdTime”: “2020-08-07T13:16:03.000Z”
}
],
“offset”: “rec8sHGXZy34yI95F”
}

Should I use JSON strings blocks?

Yes. use “get object from Json” to convert it to objects and you may use the object blocks to access the info. first level will be to get “records” from a list, then the “fields” object, followed by data column you want to read. You may use an online json ready to look at how the structure look like.

btw, assuming that this is the filtered data form your database you want to display, simply “upload” these data to the airtable that you linked to the dataviewer…So what i have been talking about previously was that you need to maintain two airtable data. (1) all data for which you filter from… (2) data to display…linked to dataviewer list/grid… Sorry I have not been clear enough, or have I misunderstood your desired outcome? why you keep saying its impossible?

Thank you so much (Can you believe me? I spend at least an hour to get object from JSON without luck and I did not notice, since your message, that “records” was a list :frowning:

So you are suggesting me to make an empty but structured table in airtable.
So I have to get the data I need in my app, upload them to airtable and then get back them displaing them in dataviewer list. Empty the table every time i need to display data.
Am I right?

Actually no need to empty the display “airtable”. you may simply add, remove or change any cells within.

It’s easiest to empty it at first instead of change every records with new data and delete it if they are more then I need or add if they are less

I guess that will work also if the data sets are not big.

Hi @Giuseppe_Geppo_Catta,

I think the following structure should work:

  • get data from airtable (with “getAllRows” or select it with “filterByFormula”)
  • in your app you can further select the desired datasets (like “James does this…”) and store the result in a local database, not in airtable. That way, every app user has its own subset!
  • the data list / data grid viewer can operate with the local database.

The local database need only to carry the columns that will be displayed in data list / data grid viewer, so the copy airtable->local database is reduced to only some fields.

Don’t forget to clear the local database first. Right now the code for iterating over alls rows from a local database is broken, I am waiting for a fix. In the meantime have a look at actech’s brilliant demo-app, there you can find code to delete an entire local DB.

Hope it helps.

“list viewer” you can use local data. But data viewer list /grid (which @Giuseppe_Geppo_Catta asked to programmatically change) has to be a global database on cloud (airtable, google sheet, or thunkable database on your account)

I notice that Creating Data Sorces for a dataviewer list there is a voice called “Create you own table”.
But It’s not clear where this table will be stored

Hi @gobassky and @Giuseppe_Geppo_Catta,

I also talk about “data viewer list / grid”. For using them you have three choices for your data source:

  • Airtable
  • Google Sheet
  • Your own table (local)

grafik

“Your own table” is stored locally, not in the cloud. After creating a table just create some columns, and after that you can assign this data source to a data viewer list or data viewer grid.

ah… @Michael_Rogulla Thanks. I stand corrected on this one.