298
Views
5
Comments
Solved
List_SortColumn reverse default sort at start of session
Question

Hi,

I'm following the online course "Developing Web Apps" and trying out the List_SortColumn.


I notice that when a new session is started (i.e. no session variables stored) and my first choice of sorting is to click on the column it is already sorted by (to reverse ascending to descending), nothing happens.  A second click on the same has the desired result.

All sorting after that works fine.  Starting with sorting on any of the other columns also works fine.


For example, on the People screen of the online course, with this as dynamic search

List_SortColumn_GetOrderBy(PersonTable.Id,DefaultOrder:"{Person}.[DateOfBirth]")

if the first click of a session is on DateOfBirth, nothing happens .


Is this known behaviour, or did I overlook something?  


I know, not a big problem, I was just curious.

Dorine

2018-10-17 18-00-19
Carlos Gonçalves
Solution

hello


List_SortColumn_GetOrderBy(PersonTable.Id,DefaultOrder:"{Person}.[DateOfBirth]")

this does not change the sorting widgets. if you want to change the sorting widget in the preparation you need to call a action called "List_SortColumn_SetOrderBy" where collumn is "{Person}.[DateOfBirth]" anbd direction is "ASC or DESC". with this when you first load the screen teh proper sort widget will be bold and with the corresponding sort.


The example you give is a default sort that will be used in case List_SortColumn_GetOrderBy() return nothing


BR


2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Hi Dorine,

Yes, this a known, annoying bug, that even happens when Service Studio scaffolds a screen for you. Like Carlos said, you may work around it by first using List_SortColumn_SetOrderBy, so the first order is explicitly set.

2021-09-06 15-09-53
Dorine Boudry
 
MVP

Hi Guys,


thank you both, this is indeed what I was missing.


So adding the Set to the screen preparation fixes this problem, but now looses the sort order when leaving and coming back to the screen during the same session.  I added some extra logic to take care of that.


For any other students going through the course, here's my solution :


* Manage Dependencies to make the List_SortColumn_SetOrderBy available

* Add a Session variable (I called mine PeopleScreenIsLoaded)

* Add logic to the preparation to set the sort order only the first time screen loads inside a session



Thanks to Carlos and Kilian for the fix,

Dorine

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Hi Dorine,

What you could do, without using a Session Variable, is to use a dummy List_SortColumn_GetOrderBy, using a non-existing DefaultOrder. If the non-existing DefaultOrder is returned as OrderBy, you know this is the first time List_SortColumn_GetOrderBy is called, so you can then use List_SortColumn_SetOrderBy (otherwise you can do nothing, assuming you have a List_SortColumn_GetOrderBy with a proper default in the Aggregate).

2021-09-06 15-09-53
Dorine Boudry
 
MVP

Hey,


thanks Kilian, that is much better than adding session variables.







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