The Dynamic filters allow us to use some filters dynamically within the views of a Dataview screen. It filters the data that we need to show on a specific screen.
Previously it was only possible to filter data for a single database on each Data view screen.
The great advantage of the dynamic filters is that now they allow us to filter the data fields from any database created in the app (relational database), which means that an app that previously required 10 or more screens to filter each of the database, now needs just a couple of screens.
Let's see how that works with a practical example.
APP EXAMPLE WITH A LIST OF COUNTRIES AND CITIES
We want to create a DB which contains a list of Countries and Cities.
With the “old” system it was necessary to create an option list with the list of Countries and connecting each Country to a specific data view (screen), and then filter them for cities in each data view.
In this example we have created at least 7 screens.
Each data view screen of a specific Country could be filtered by selecting the field (Cities) -> include -> Country name, as in the following image:
Where is the change?
In the following example the filters allow us to create only 2 screens and to filter all data dynamically.
Or rather, the filter will change depending on the database we are filtering.
Let's see that in our App example.
- In our App we have a splash screen as presentation that leads to a screen (data view) named "Categories".
Here we will create a database with a field named "Countries", where we insert a list of Countries we want to show.
2. Now let's create a list view where we will drag the dynamic text element (pink) which refers to the field of the database "Categories" that will be the field: [Countries] and we will tell it to open the "Filters" screen, which will be a new data view screen that we are going to create.
The "Filters" screen is the screen containing the filter or dynamic filters and will be the screen that will show us the data we want to display (i.e. the Cities related to each Country).
3. The new "Filters" screen contains a database with two columns:
a) The first one with the Countries "Countries"
b) The second one with the Cities "Cities"
Now we want that, when the user is on the "Countries" screen (the first created), when clicking one of the Countries of the list, he could see the Cities of the same Country.
This is the reason why we must use a filter on the second screen that has been created: "Filters" so that we can show the Cities´ information related to a Country.
4. So let's put a filter on the "Filters" screen as demonstrated in the following image:
In the picture we see that, in order to show the City of a specific Country, we must use a filter that is called by the database of the first screen "Countries".
We will tell the filter to show us the field (cities) that we have in the database that we are working on, and to filter them by the condition ("Include").
In the compositor we must select the field which should be included (show) in the filter. In our example we will choose (Categorias.Countries), which will be the field of the first screen created, which contains the list of Countries.
What does the field (Categorias.Countries) mean?
Categorias -> is the name of the database we want to filter (the one from the first screen).
Countries -> is the field name, in text format, containing the information of the countries, from the first database created.
This way, when clicking on the list of the countries of the first screen, we ask the dynamic filter to automatically display only the cities related to this Country.
The filter will detect the selected Country (for this reason the filter is called dynamic because it changes) and displays this information in the "Filters" screen, showing the cities related to the chosen country.
If the user will choose Spain, for example, it will show a screen with the cities of Madrid, Barcelona and Seville, as in the following example.
Then you can create a detail view, in the "Filters" screen to view the details of each city.
It is only necessary to assign to the City field, in the list view, the action: go to view: DETAIL_1 so that the user can view the details of a specific City.
The end result will be like this:
See also the video tutorial on our Youtube channel on: Dynamic filters and relational databases in Mobincube