Hello!
I have a canvas app with a gallery & have 3 different fields I need to allow the user sort ascending/descending like a toggle.
Gallery Items are from a collection named collTasks
Sample gallery with items:
Task | Age button onselect : Set(varAgeSort, Ascending, Descending) | StartDate button onselect : Set(varStartSort, Ascending, Descending) | UpdatedDate button onselect : Set(varUpdatedSort, Ascending, Descending) |
Task 123 | 14 | 9/1/23 | 9/26/23 |
Task ABC | 34 | 8/15/23 | 9/20/23 |
Task UNO | 3 | 9/24/23 | 9/27/23 |
So far I've got:
SortByColumns(collTasks,
If(!IsBlank(varUpdatedSort),"UpdatedDate","Age"),
If(!IsBlank(varUpdatedSort), varUpdatedSort, varAgeSort),
"StartDate",varStartSort)
basically trying to say that if the user has selected the Updated Sort button, sort by that column & in the order captured in the variable varUpdatedSort, and same with Age & then StartDate - but the data needs to be sorted in the order the user hits the toggles. meaning if they hit "Age" first then UpdatedDate second, then the sort order should be "Age", value in varAgeSort, "UpdatedDate", value in varUpdatedSort. but then if the user hits varAgeSort toggle again, the sort order should be "UpdatedDate", value in varUpdatedSort, "Age", value in varAgeSort.
is there a better way to tackle this? any guidance would be most appreciated, thanks!