When you create model driven apps you would expect to create Dataverse views to display your data, but how about Canvas apps? In this post an easy way to create a dropdown to control your data in your galleries.

Dataverse Views

Within Dataverse we can create tables and for Tables we can create views, that display either a prefiltered number of records or it would give us a set of columns that we can display to the user.

Views in Dataverse on my car details table
Views in Dataverse on my car details table

Galleries in Canvas Apps

Within Canvas apps we can create galleries, so that we can display data from a datasources. So Typically we could specify a table to feed our Gallery.

Canvas App showing data from my car details table
Canvas App showing data from my car details table

Set the View in a Gallery

Now you could select the View of the Gallery using the dropdown in the Gallery properties, however if we want to leave it up to the user to select the views, then we might want to add a drop down to our screen.

Gallery using a View as a data source
Gallery using a View as a data source

Create a Dropdown with all views

We can add a dropdown that gives us all the Views available within the table that we have selected as a data source. Using the Choices function we can then get a list of views.

Use Dataverse views to feed a dropdown
Use Dataverse views to feed a dropdown

Use the dropdown to control the Gallery data

Now all we need to do is update the Items property on the gallery to include our view selected in the Dropdown control and we are done.

Use the dropdown with Dataverse Views to filter the gallery
Use the dropdown with Dataverse Views to filter the gallery

Benefits

Ok, this may not look that much better than just adding the filters to your code in the Canvas app. However, by using views the queries will run more effectively as you will not see any delegation errors. Following the general rule of thumb that the data manipulation should be done as closely as possible to the data rather than the user interface.

By letting your data layer handle the complexities of the data filtering, you should see performance improvements in your apps.

So compare these views a bit with SQL views or stored procedures. If you can use views or stored procedure in SQL that that is always better than reconstructing the same within your apps that read their data from SQL.

And how about accessing data from multiple tables. Or filtering data by having related records in another table. Using Dataverse views makes that all possible.

Make use of Dataverse Views in Canvas Apps
Make use of Dataverse Views in Canvas Apps 1

Discover more from SharePains

Subscribe to get the latest posts sent to your email.

Related Posts

2 thoughts on “Make use of Dataverse Views in Canvas Apps

  1. Any idea how to use a Dataverse view as the filter but to also have the sorting from the same Dataverse view applied?

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.