Power Apps - Row numbers
Power Apps - How to

Power Apps - Row numbers

Last week Shane Young posted a new video on YouTube and part of this video was dealing with row numbers. There is no out-of-the-box capability for row numbers on galleries, but sometimes we like or need them to be able to build a striped grid. Shanes blog on the topic you can find here!

Now, Shane uses multiple collections and a few extra controls and formula besides the gallery itself to achieve the result. A nice solution, but it still makes me think of how I should approach this question. And I think I came up with another solution, so let me know what you think after checking this out?

In my video on YouTube Learn Power Apps | 43 | Gallery RowNumbers I will share my approach on how to add row numbers to the gallery. I nice thing about my approach is that I use scoped formula's and with those formula's prevent the need to use extra controls, formula's and collections to add those row numbers.

In Short: I use the With() formula on the gallery to set a temporary memory spot and within the With() formula do some data manipulation. Next, I use the ForAll() formula to loop through my records, only I don't use the records themself, but the Sequence() and CountRows() formula. If you have a Code background, basically I change the logic from a ForEach to a For i, i < numberofrecords, i+. With the Sequence, we now have a counter for the row numbers, so the first goal achieved right.

We now only need to add this row number to the appropriate record which we can do with a simple Patch() formula. To get the right record we use Last() en FirstN() formula's and in the FirstN() formula we use the sequence to get the right amount of records to then to take the last of this table with the Last() formula.

Now we only have to apply a simple formula with the use of If() and Mod() on the gallery.TemplateFill property to get those row visuals. And we are almost done.

One thing we need to fix is the schema we return to a record variable when we click an item in the gallery. Here I use a LookUp() formula which gets the right record from the gallery.AllItems while dropping that row number column first with the DropColumns() formula.

So now we added row numbers on the gallery itself and removed those on click to keep the rest of our App logic in place. Hope you like my approach on this topic. Let me know in the comments?

And again, heads up for Shane for his great videos.



要查看或添加评论,请登录

Paul Kroon的更多文章

社区洞察

其他会员也浏览了