
Announcements
Hello,
I have a gallery that has the following formula on the Items property:
Sort(
Filter(
Records,
WITHDRAWN = false,
StartsWith(
Title,
TextInput1.Text
) || StartsWith(
'StudentNo ',
TextInput1.Text
)
),
Created,SortOrder.Ascending
)
I was wondering if it is possible to add a Sort button so when pressed, it will then sort the gallery by name (column is the Title field in sharepoint).
Default sort and filter is as shown above, but if you click on a sort button then it will sort the list by Title and alphabetical, then have a reset option to switch back to default sort.
Can anyone help or advise how i can achieve this?
thanks
@neill_long - one method:
On the OnSelect property of your Button control, enter:
UpdateContext({ctx_sort_column: "Title"});
UpdateContext({ctx_sort_order: !ctx_sort_order})
On the OnSelect property of your reset Button, enter:
UpdateContext({ctx_sort_column: "Created"});
UpdateContext({ctx_sort_order: true})
The modify the Items property of your Gallery to:
SortByColumns(
Filter(
Records,
!WITHDRAWN, //cleaned up. this has nothing to do with your question
StartsWith(
Title,
TextInput1.Text
) || StartsWith(
'StudentNo ',
TextInput1.Text
)
),
ctx_sort_column,
If(
ctx_sort_order,
SortOrder.Ascending,
SortOrder.Descending
)
)