How to sort records fetched from rest api and bind to table records widget ?

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:


 

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

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?

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

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 ?

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

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?



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,
        ...)) 

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