List_SortColumn in List Records

Hello!

I'm noticing that List_Sort Column widget is quite common on a Table Records, but when it comes to a List of Records, some challenges arises.

I want to use the List_SortColumn widget on a List of Records that has a Special Structure (4 column gallery).

Further that, I've already added the following dynamic sort on the List Records Aggregate:


List_SortColumn_GetOrderBy(MainList.Id, "{Product}.[Price]")



The problem is, when I open on Browser, it's already ordered by Price (Ascending), and I want to click on the Price and order Ascending/ Descending. 

Below, there's a picture of the page rendered and notice that no action can be done on the Price.



Thanks in advance,

ruipmoura

You'll need to set your price as a link to give it some sort of action or even when the user taps/clicks on it

The way that i've accomplished this in the past is to set your price as a link.  
The link would navigate to some sort of sorting "action".
In that action, I've set a local var as ASC or DESC.    
Pass that local var into the aggregate that is the source for your list as a parameter in the Sort.  

Or, you can try this component: https://www.outsystems.com/forge/component-overview/2671/list-record-sort

That was made to do the same thing as the one from RichWidgets, but works with List Records :)

Cheers

Timothy Franklin wrote:

You'll need to set your price as a link to give it some sort of action or even when the user taps/clicks on it

The way that i've accomplished this in the past is to set your price as a link.  
The link would navigate to some sort of sorting "action".
In that action, I've set a local var as ASC or DESC.    
Pass that local var into the aggregate that is the source for your list as a parameter in the Sort.  

I've created a Local Variable inside the "Sorting" action, to where the link navigates, but I don't understand how to "Pass the local variable into the aggregate" (I have no idea how to pass this local variable, that's inside an action, to the aggregate in the preparation). Can you be more specific, please?


Eduardo Jauch wrote:

Or, you can try this component: https://www.outsystems.com/forge/component-overview/2671/list-record-sort

That was made to do the same thing as the one from RichWidgets, but works with List Records :)

Cheers

Eduardo,

I've found it before, and tried, but unsuccessfully, since when I click on the price, it changes the shape of this special 4 column gallery to a 1 column gallery. 


If you want, I can show what happens on the Browser.


Thanks,

ruipmoura


Please.

I would like to understand, once this shouldn't be happening, once the widget does not have any direct impact on the list, only in the source.

Could you show also how are you implementing the On Notify action?

Cheers.

Eduardo,

Here is how I added this Rich Widget, next to Price expression:


And the OnNotify action is set as follows:

And as you noticed, I've kept the Sorting on the aggregate. Should I take it out?


List_SortColumn_GetOrderBy(MainList.Id, "{Product}.[Price]")


The first time I click on the Price on the Browser this Special Gallery turns as follows:

Thanks in advance,

ruipmoura

Rui Pedro Moura wrote:

Timothy Franklin wrote:

You'll need to set your price as a link to give it some sort of action or even when the user taps/clicks on it

The way that i've accomplished this in the past is to set your price as a link.  
The link would navigate to some sort of sorting "action".
In that action, I've set a local var as ASC or DESC.    
Pass that local var into the aggregate that is the source for your list as a parameter in the Sort.  

I've created a Local Variable inside the "Sorting" action, to where the link navigates, but I don't understand how to "Pass the local variable into the aggregate" (I have no idea how to pass this local variable, that's inside an action, to the aggregate in the preparation). Can you be more specific, please?




I'm sure i'm not explaining very well,  so let me know if I can elaborate any further.  

This was the very first Outsystems project I worked on, so i'm sure there's a better way to accomplish this.   I saw the forge component @Eduardo mentioned after I had already finished the project, so it might be easier.   However here's how I did it.


On the click of the link, i'm launching "OnColumnSort" action.  In that action it's doing something similar to the default "RefreshTable" action that OutSystems generates when you have a template using a list table.   I'm passing in SortedColumn as a parameter and using that inside the Aggregate's Sorting tab.  SortedColumn just contains the name of the column as a string and "direction" is just toggled between ASC and DESC with an if in the workflow. 

Hi, 

First thing I notice, is that if you are using the ListRecord_SortColumn (instead of the List_SortColumn from RichWidgets), you should also replace the:

List_SortColumn_GetOrderBy(MainList.Id, "{Product}.[Price]")

By:

ListRecord_SortColumn_GetOrderBy(MainList.Id, "{Product}.[Price]")

From the forge component. 

But this is not what is causing the problem (if you have a 4 column gallery instead that is turning into a 1 column).
In fact, I would say this problem is not related to the use of the widget (most likely).
I'm telling you this there is nothing in the component that acts upon the gallery or the list, directly. It only sets a session variable (internally) associated with the id of the table, that is used to recover the selected field later in the function in the Aggregate.

So, it is your Ajax Refresh over the List/Gallery that is somehow causing this, I would say.

How is your gallery configured, could you show the configuration of the gallery AND the List inside it?

Cheers.


Solution

In any case, I found why you are having this behaviour.
Don't ajax the LIST RECORDS in the notify.
Ajax the GALLERY. This will keep everything working :)

Cheers.

Solution

Eduardo,

The change of statement in the Aggregate's Sorting, has already solved half of the problem - each time I click on the Price, it changes form ascending order to descending. It still changes from 4 column to 1 column Gallery.

Meawhile, and analysing the Ajax Refresh on the OnNotify action, it was set to the widget MainList:


I've changed to List_Wrapper and the problem is SOLVED, Mate :D


I appreciate your precious help, Thanks!

Regards,

ruipmoura

Tim F.

I Thank You also for your dedication, however, I would prefer the way Eduardo suggested.


Best Regards,

ruipmoura

You're welcome :) 

Rui Pedro Moura wrote:

Tim F.

I Thank You also for your dedication, however, I would prefer the way Eduardo suggested.


Best Regards,

ruipmoura

Hey, No problem at all!  I'm still new to Outsystems, so I learned something as well.