cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Super User
Super User

Re: Gallery Overlay Question

You won't always have a row number in your dataset (for example, I use this method a lot to put overlays on images using data returned as JSON from Cognitive Services Vision API) so here is a trick to generate a RowNum column for any collection. Given your data shown below:

ClearCollect(colMapPins,
    {region: "System Wide-1", x: 140, y: 180},
    {region: "System Wide-2", x: 140, y: 310},
    {region: "West-1", x: 317, y: 145}, 
    {region: "West-2", x: 527, y: 139}, 
    {region: "West-3", x: 460, y: 399},
    {region: "West-4", x: 280, y: 335},
    {region: "East-1", x: 620, y: 240},
    {region: "East-2", x: 775, y: 115}, 
    {region: "East-3", x: 923, y: 300},
    {region: "East-4", x: 636, y: 455}
)

You can do the following (needs be triggered by an action such as OnVisible or OnSelect):

Clear(colMapPinsWithRow);
ForAll(colMapPins,Collect(colMapPinsWithRow, {region: region, x: x, y: y, RowNum:CountRows(colMapPinsWithRow)})

This will give you a new collection adding the column RowNum which will start at 0 and increment 1 for each row.

Use the collection with RowNum for your Gallery's items property. When positioning your icons you can set the Y value (assuming a vertical gallery) to 

ThisItem.y - ThisItem.RowNum

Would be great to really be able to set the templatesize to 0 (if you try it actually reverts back to 1) or have a built-in ability to determine the row number of an item in a gallery, but this trick seems to work.

Highlighted
seadude
Level 10

Re: Gallery Overlay Question

Awesome contribution Paul!
Thank you!