How is your experience with the OutSystems Community?
380
Views
8
Comments
How to sort records fetched from rest api and bind to table records widget ?
Question

I am binding data "filteredcategorylist' to table records widget and implemented search. Now I want to add sort to the response recieved from API.

I have added image of RefreshTable action and this is working fine with search. How can I add logic for list sort to the filteredcategorylist.




Richwidget_Sortcolumn is binded as:


 

2021-03-05 13-56-11
Ricardo Pereira
 
MVP

Hi,


You can use the The ListSort:


You can define the list that you want to sort, The attribute and if it'as ascending or descending.

Is this what you need?


Hope this can help!


Best regards,

Ricardo M Pereira

UserImage.jpg
Shikha Basra

Hi
Ricardo Pereira


I have used List sort and added sorting on CategoryName and it is working fine. 

If I click on CreatedDate and sort should work for it as well. How can I accomplish that?

How Can I made it to work for other columns?

2023-04-07 07-55-02
Krushna Mantri

Hi Shikha,

Good Evening!!

Could you please take column name as an Input parameter in RefreshCategoryTable and put that in List sort's "By" attribute

Regards,

Krushna

UserImage.jpg
Shikha Basra

ok. But How can I find the sort column name to pass as input parameter?  Do I need to get clicked sort column using javascript? or there is any event in which I can get the value of sort column clicked ?

2024-02-16 07-43-18
Amit Verma

Hi Shikha,

Please take a look in this answer:

https://www.outsystems.com/forums/discussion/21343/multiple-attributes-sort-on-listsort/

Hope this will helps :)

Thanks,

AV

UserImage.jpg
Shikha Basra

HI Krushana Mantri,


I did the way you told me.

I debugged the code and I am getting correct attribute in SortBy Input parameter in RefreshCategoryTable on sortcolumn click.

But ListSort server sction  is not picking the List Sort 'By' attribute correctly . Am I doing wrong somewhere?



UserImage.jpg
Shikha Basra

Sorting is working fine now by passing input parameters. The only thing is to specify parameters in List Sort By like 

https://www.outsystems.com/forums/discussion/34940/listsort-vs-sortrecordlist-sort-by-passed-as-text/#Post123681

If(AttributeName = "FirstTextAttribute",
    FirstTextAttribute,
    If(AttributeName = "SecondTextAttribute",
        SecondTextAttribute,
        ...)) 
2019-11-11 17-10-24
Manish Jawla
 
MVP

Hi Sikha,

you can check the below forge component as well for multiple attributes used for sorting.

https://www.outsystems.com/forge/component-overview/22/sortrecordlist

Regards,

Manish Jawla

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.