3

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.

Dmytro
  • 16,668
  • 27
  • 80
  • 130

2 Answers2

3

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.

carlosfigueira
  • 85,035
  • 14
  • 131
  • 171
1

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/

Pranav Patel
  • 1,541
  • 14
  • 28