[Paginating Data Action Example] How to provide TableSort a default value that’s equal to whatever column is sorted on
Reactive icon
Forge component by Kilian Hekhuis
Application Type

Hi Killian,

Thank you for your document on how to work with paginating, sorting and filtering data from a Data Action. It is very accurate and helpful.

There is only one thing not working for my implementation. Indeed when the user tries to sort a columns header for the first time nothing is happening. In your article you describe that you:

"One final thing to do is to give TableSort a default value that’s equal to whatever column is sorted on, if the Data Action returns a sorted list (typically the REST method or Service Action will return the list sorted by some attribute, alternatively you could use ListSort in the Data Action to sort it after retrieval)."

I can't figure out in what action you can do that assign. It is not possible to do this in the declaration of the variable:

Can you please explain in what data action you are doing that assign? I tried to check your example but I can't find that assign.



Hi Rogier,

I don't quite understand why you couldn't set the Default Value to e.g. "Name" when it's sorted on Name?

If that's not something you want to do, or want to set the sort dynamically, an alternative is to do it in the OnInitialize of the screen.

Thanks you Killian,

The TableSort variable is used by two or sometimes three columns (with the value of the variable ClickedColumn). If I would give it the string value (for example "name") of the first column as a default value and the user would click on a different columns for the first time then I suppose this is not an option. But to put it in the on initialize is a good option I will certainly try. I have to see if that has no negative effect on the other actions. 

I will let you know if this worked.

Hi Rogier,

Setting the TableSort is needed if the data comes already sorted. So if it's sorted on Name, you set it to "Name" etc. This prevents the case where the user clicks the column and it isn't sorted in reverse, because the app doesn't know that the column was already sorted. But anyways, I'm glad it now works for you!

I tested your option to put it in the OnInitialize. This worked perfectly.

Thanks Killian.

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