I wanted a way to identify what row I was using in my gallery so that I could refresh the data and return to the same place. There’s no obvious way to do this from the gallery, so I’ve written a workaround.
RoundDown(
Find(
Text(
RecordsGallery.Selected.ID,
"[$-en-GB]000000"
),
Concat(
[@YourDataSource].ID,
Text(
ID,
"[$-en-GB]000000"
),
" "
)
) / 7 + 1,
0
)
This looks at the ID number for the current selection in Records Gallery and makes it six digits long. It then tries to find that six digit number in a concatenated string of all the ID numbers you currently have in your source. The result is the row number.
This enables me to have a gallery using a collection which can be sorted by all sorts of fields. The sortation is applied to the collection itself, and I search for that ID number in the collection.
When I refresh my data, I save the current row number as a variable
Set(
varRowNumber,
RoundDown(
Find(
Text(
RecordsGallery.Selected.ID,
"[$-en-GB]000000"
),
Concat(
[@YourCollection].ID,
Text(
ID,
"[$-en-GB]000000"
),
" "
)
) / 7 + 1,
0
)
)
Clear my collection, pull fresh info into the collection, then select the row number again
Select(RecordsGallery, varRowNumber)
You might want to add some error handling. For example, if you have a collection of tickets in Open status, you’re selecting the bottom one, and that ticket has the status changed to close before the next refresh… the RowNumber that you save will be greater than the amount of actual rows
//Save the row number
Set(
varRowNumber,
RoundDown(
Find(
Text(
RecordsGallery.Selected.ID,
"[$-en-GB]000000"
),
Concat(
[@YourCollection].ID,
Text(
ID,
"[$-en-GB]000000"
),
" "
)
) / 7 + 1,
0
)
);
//Refresh the data
Clear(colTickets);
ForAll(
ComboBoxStatus.SelectedItems As CBStatus,
Collect(
colTickets,
Sort(Filter(SharePointList, SharePointColumnStatus.Value=CBStatus.Value),ID,SortOrder.Descending)
)
);
//Error Handle if you now have less tickets and happen to be selecting a high number
If(
CountRows(RecordsGallery.AllItems) < varRowNumber,
Set(
varRowNumber,
CountRows(RecordsGallery.AllItems)
)
);
//Reselect my ticket
Select(RecordsGallery, varRowNumber)