cancel
Showing results for 
Search instead for 
Did you mean: 
happyume

How To count rows for gallery with more than 100 records

One of the recommended ways to count number of items in a gallery control is:

 

gallery1.AllItemsCount

 

 

However, this has a limitation that it can only show count of 100.

When the user scrolls the gallery further, the count updates in an increment of 100.

This may not be an effective way to show total number of items.

 

Solution:

We create a hidden gallery and set the default property to last item.

This simulates the action of scrolling all the way to the end.

We then count the number of records in this hidden gallery.

 

Here is a step by step guide:

1 - Add a new gallery control - gallery2

 

2 - Within the Items property of gallery2, copy the same code from the Items property of the original gallery (gallery1). Do NOT use gallery1.AllItems

 

3 - We don't have to add any controls within this new gallery (gallery2)

 

4 - Add default property for gallery2 as:

 

Last(Self.AllItems)

 

 

5 - Hide the new gallery (gallery2) by setting Visible property to false

 

6 - Add a label and set property to:

 

gallery2.AllItemsCount

 

 

This way you have simulates the action of scrolling all the way to the end in gallery2 without impacting your user experience. Since you have scrolled all the way to the end, you can get accurate count for number of items in the datasource.

Comments