Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get gallery item index in PowerApps?

Tags:

powerapps

I created a simple news browsing application with PowerApps. To display articles list I use Gallery control named NewsGallery. The data source for it is my custom api that returns the collection of Articles. My article entity contains of Text, Title and TitleImage. Let's say I want to display a number of an article in my NewsGallery. I can access the bound data through the ThisItem operator and can easily display my article's Text, Title or TitleImage. Also, as it is mentioned in this article, I can determine either the item IsSelected in the gallery using ThisItem operator: ThisItem!IsSelected. So can I get the index of an item in my NewsCollection also using ThisItem operator? Or is there another way? As a workaround I can pass this value through my custom api but I wouldn't want to do that.

like image 754
Dmytro Avatar asked Oct 24 '25 03:10

Dmytro


2 Answers

Currently there's no way to get the selected index of an item in a gallery. You can, however, access all properties of the selceted item, so if you own the custom API that you're using to populate the gallery, one possible way to implement that would be to add the index to the objects being returned.

Another way would be not to use the index, but to use some sort of identifier for the items returned (something like a primary key) that would normally be returned as part of the API, and you can access via Gallery.Selected.Id.

You can also create a new issue in the PowerApps Ideas Board to make a suggestion to the product team to add this property to the gallery control.

like image 77
carlosfigueira Avatar answered Oct 26 '25 19:10

carlosfigueira


I found article which shows the index (sequence number) of gallery item even after apply the different filters. I checked and it is working fine with directly data sources instead of using collection. http://powerappslearning.com/serial-number-index-number-in-gallery-control-powerapps/

like image 36
Pranav Patel Avatar answered Oct 26 '25 18:10

Pranav Patel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!