Data Views: When and Why?

Trying to wrap my head around something. When and why would you use ‘Data Views’?

Anyone have any good examples?

Same with ‘Data Iterator’? I have a feeling I am missing out on some good features …

Hello Brad,
What data view does is making the data available on the clientside - good for small data sources ~ up to 2-3k records.
It loads the data at once and then you can really fast filter, sort or browse through the records clientside - as the data is already loaded.
So if you have small data source there is no need to call the server action (and load the server with a call) every time you wish to sort the data, or filter it.

1 Like

With Data Iterator, you can display one record at time on your page and loop through all records, using previous, next, first, last, random, or go to specific record actions.
So it is a really easy way to setup a repeat region showing one record at time and loop through the rest.

1 Like

Thanks for the explanations. I look forward to seeing some documentation on using those in the future. I am sure there is many times, since all I really do is work with data, that these would have been more practical.

Just not sure how to use them at this point.

Well i think it is already explained in my posts above - for small data sources you load your data at once in your browser, then it is available for really fast paging, sorting and filtering, as you don’t wait for server to execute requests and reply.
Data iterator can be useful for a news rotator, where you jus show one item at time. Imagine you have to create a normal repeat region, limit it to one record, sort it, add next/previous buttons and still looping won’t be available without the iterator component.

Can’t seem to find any DW Extension videos on using Data Views and Iterators? Perhaps I could get some ideas from those. IS there any?

Can only see one and that is adding the new paging feature to a data view but nothing on setting up a data view.

Please check here: https://www.dmxzone.com/go/32776/dmxzone-app-connect-data-traversal/

2 Likes

Well that was easy. Glad I asked the question. So simple to use and makes sense to use it as well. So if I understand correctly:

Data View: Loads the entire database table and is sorted, paged, filtered, etc on the client side?
Paged Recordset: Has to make a new call to the server each time a recordset is paged, sorted, filtered, etc?

Am I understanding correctly?

Yes these are the differences.
The paged query and the normal query always make calls to the server, which executes them, replies and then the data is rendered when filtering/sorting on the server-side (in server connect), which is not always a bad thing of course.
In some cases (data sources with huge amount of data) it is better to do this server-side.

Thanks Teodor, I am now one tiny step closer to being a Wappler expert lol

1 Like

Nice topic with clear explanations

1 Like

Just to confirm - this is not actually the case is it? As far as I understand it, all of the query results are loaded (even if paging is going to be used) - not necessarily the entire table.

Presumably the amount of data wouldn’t matter unless the number of query results was also expected to be huge. ie if you had a million records in a table, but only expected up to 500 results to be returned from a query, then using client-side sorting and paging etc. would still be suitable. Or is this not the case?

I seem to remember seeing an option to limit the number of results returned by Server Connect. Does this exist or is there a default limit?

Hello Tom,
Yes it is the QUERY result which gets loaded. If you have a million records and expect 500 results from a query you can use the clientside filter/sort etc. options of Data View without any worries.

There is no option to limit a query results in the normal query. This is available in paged query, where you can define limit.

Thanks for confirming that Teodor.

we are telecom operator in turkey … our call detail reports millions … so this is really usefull for us :wink:

Am just looking at data views…

So @Teodor, is this data view:

<dmx-data-view id="activities_undeleted" dmx-bind:data="activities.data.activities" filter="is_deleted==0"></dmx-data-view>

Exactly the same as this:

activities.data.activities.where(`is_deleted`, 0, &quot;==&quot;)

??

Or is there some difference in terms of performance and resource utilisation?

If they are the same, then the benefit of using the data view is that I don’t have to keep typing activities.data.activities.where(is_deleted, 0, &quot;==&quot;) ??

@Antony, I have always been a fan of Data View… It makes the server-side a lot simpler and the process super fast because the filtering is done on the client.

The drawback - every great plan has a draw back - I think that it is best to limit using Data View to no more than about 3,000 records. With my home and garden type website, this has not been a problem.

1 Like