Hi Experts,
I am using below formula
SortByColumns(Filter([@'datasourcesharepointlist'], StartsWith(Title,SearchBox.Text)), "Title", If(SortDescending1, Descending, Ascending))
Now this is only working to sort on one column (title column)
How can i sort on other columns ?
unfortunately delegation will be there when using SortByColumns with variables. You can try this:
running different sorting based on condition. Like keep the code on sorting buttons same. But change your gallery code to this:
If(varColumn="Name",
SortByColumns(
Filter([@'datasourcesharepointlist'], StartsWith(Title,SearchBox.Text)), "Name", If(SortDescending1, Descending, Ascending)),
if(varColumn="Availability",
SortByColumns(Filter([@'datasourcesharepointlist'], StartsWith(Title,SearchBox.Text)), "Availability", If(SortDescending1, Descending, Ascending))))
and so on.. So instead of usinf variable directly in sorting logic. You are running different sorting logics based on condition.
@zmansuri
Awesome this works but now I am running into a delegation issue of 500 items (My list has more than 3000 + items)
Gallery:
SortByColumns(Filter([@'datasourcesharepointlist'], StartsWith(Title,SearchBox.Text)), varColumn, If(SortDescending1, Descending, Ascending))
Sorting Button Beside Name field:
OnClick:
UpdateContext({varSort :"Name"});
UpdateContext({SortDescending1:!SortDescending1});
Sorting Button Beside availability fields:
OnClick:
UpdateContext({varSort :"Availability "});
UpdateContext({SortDescending1:!SortDescending1});
In Short every time you click your sorting button beside field name. It will set the column name of that field in the variable varColumn
So in your gallery code where right now you have written "Title", which is why it is sorted by title. It will be varColumn instead of Title. And varColumn will change with buttoin click
Hello,
Thank you for replying to my post.
Could you guide me how to write it. I am not a developer. I just learn from youtube and blogs 😃
Instead of colum name in your gallery code use variable like "varColum"
and onClick of your sorting arrow update the variable with columname using UpdateContext. So whichever sorting icon you click column name will be changed according