sorting by different attributes

Hi,

I am trying to have a feature where i can sort how a list of items gets displayed. I am planning to allow users to be able to sort a list of items by Last Created, Alphabetical order and price. So in the listing gallery page, there will be a dropdown of "Last created", "alphabetical order" and "price", where they will choose and after that the list will sort according to what they choose. 

I saw on some of the forums where i can use the server action of listsort, however i am not sure how to implement the logic. i tried to follow the suggestion in this forum https://www.outsystems.com/forums/discussion/52818/sort-list-from-local-variable-displayed/ but because i am developing a native app, there is no ajax refresh. 

I need help with the part of refreshing the aggregate that is populating the list in my listing gallery after sorting is done. Currently, i am populating my list with an aggregate which i fetch from the database (so only one type of sorting). If i were to have different sorting attributes, should i populate my list with a local variable instead or?

I also need help with the dropdown  to contain the words "last created", "alphabetical order" and "price". Do i have to created a separate static entity to have these 3 words as records, so that i can populate my dropdown accordingly? Or is there another way to populate my dropdown? 

Hello Jolene,

For the sort issue, please see here how ou can sort by multiple fields: https://www.outsystems.com/forums/discussion/21343/multiple-attributes-sort-on-listsort/#Post83682

As you are working with reactive/mobile, you dont need to use ajax to refresht the data.

Can you try this?


About the dropdown, you need to create a new attribute with the values of the 3 attributes or create a structure for that.

If you need more help, you can send your oml and I will help you to solve those issues.


BR,

Luis

Luís Cardoso wrote:

Hello Jolene,

For the sort issue, please see here how ou can sort by multiple fields: https://www.outsystems.com/forums/discussion/21343/multiple-attributes-sort-on-listsort/#Post83682

As you are working with reactive/mobile, you dont need to use ajax to refresht the data.

Can you try this?


About the dropdown, you need to create a new attribute with the values of the 3 attributes or create a structure for that.

If you need more help, you can send your oml and I will help you to solve those issues.


BR,

Luis

Hi Luis,

I attached an oml and explained what i did:

1) i created an static entity "sort" with the follow attributes: last created, alphabetical order and price.

2) On the listing gallery screen, i fetch this entity. I also have a local variable "sorting", which the data type is text. So for my dropdown, the variable is the local variable "sort" and the list for the dropdown is "get sort". 

3) i tried to use the dynamic sorting in the "get sort" aggregate to sort by the local variable "sort".

4 ) Also, since it is a dropdown, i created a client action of dropdownOnChange in order to refresh the aggregate? 

However, i tried the app and got the error of "error in executing query". 

Solution

Hi Jolene,

I have made some changes in you oml.

The problem was that, you have not assigned the column by which you wanted to sort.

I have also attached the update oml for your refrence.

Hope this helps you !!


Regards,

LK

Solution

Lakshmi Kumar Yadav wrote:

Hi Jolene,

I have made some changes in you oml.

The problem was that, you have not assigned the column by which you wanted to sort.

I have also attached the update oml for your refrence.

Hope this helps you !!


Regards,

LK

Hi LK,

Thank you for your help. I have another question, if i were to input in the factor of sorting by either descending or ascending, do i just change the right assignment of the list sort (in the pic)? or do i have to create another local variable to store whether it is descending or ascending? 


Hi Jolene,

I would recommend you to go through below link. This has detail information on how to use sorting on table and list.

https://www.outsystems.com/learn/courses/143//?LearningPathId=18

for ascending/descending functionality, you have to somehow manage the code so that the value of ListSort be like

For this you can use another variable or some other approach, whichever suits you better.


Thanks,

LK