Dear all,
I see this question a lot, but never found a useful answer.I've a table based on a local record list (so no aggregate/sql), please don't ask why...........The header of the table uses the sort attribute which is a attribute from the local record list.The used OnSort has on input of text obviously.Based on that input a use the ListSort to sort the Local Record List, but that obviously does not work.If I use the following in the input parameter 'By' from action ListSort, obiously the list is sorted.
If(SortBy=Address.Zipcode,Address.Zipcode, If(SortBy=Address.City,Address.City, If(SortBy=Address.Number,Address.Number, If(SortBy=Country.Name,Country.Name, If(SortBy=AddressType.Name,AddressType.Name,Address.AddressNumber)))))
Personally, I don't like this method.So is there any other way (not using an if or a switch)??
If there isn't, it certainly would be nice if something like this would be 'solved' by OutSystems.
Best regards,Jeroen
Hi Jeroen,
I guess the table sorting is built with aggregates/sql in mind, and this is probably also the largest number of use cases. Yours is not for aggregates ,but I'm not supposed to ask ... :-)
So, while waiting for OS to improve on this, it is possible to fabricate your own IF and SWITCH free sorting with javascript, but this is fragile / a bit hacky.
See attached oml, the sorting is done in javascript, this is fragile because it makes use of the $public variable, and this code might break with future versions of OS platform. Also, if you really want to do this, maybe find out how to trigger a rerender of the list, that's nicer than what I'm doing now.
This is a very simple example list, when it is a list of records, the exact way to build the element name / list name might be a bit different.
Dorine
Hey,
If you have local record list and want to sort it then onshore action use lists sort and assign result of list sort to you local record list variable again.
Hope this will help you.
Thanks
Yogesh
Yogesh,
maybe I don't understand you replay, but the listsort does not work in this case ..
@All,
apparently the listSort doesn't work when using a field-name (text) in the by parameter.I created a script which overrules the OutSystems default system-ListSort.So now it's working for both text 'fieldnames' and GenericType fields, including the re-render of the table, if there's any.Also created a supportticket, so hopefully OutSystem will solve this themself also......Best regards,Jeroen
can you share here how it works, or is this protected by some intellectual property rules ?
Hi,Though tried, I failed to find a solution with SortAttribute property for header cell. But there is a way to get this resolved.#1: For a Static table / Table without Pagination use the extension TableSort.#2. While for a table with Pagination having an aggregate as source > First add a sort variable to the page /block > In the aggregate set the Dynamic Sort Property & set this variable. > On click on each column header call a client function and set the Sort variable value to the column value. or pass it as a parameter > in the client function refresh the list.Hope this helps.