How to Sort true/false values in descending order on a table?
Question

I have created a table that has 7 questions and a comments sections. I've added dynamic sort (followed one of the How To's from Outsystems) and it works fine. However the results once clicked on the "Sort" get arranged in ascending order (sort By second column )(false displays on top which I have to keep empty if false) and I need the sort to do the opposite (True first, False below). What would be the simplest way to implement this? I tried changing the Sort on the Core Entity, but it didn't help and I can't choose it on a variable.


Solution

If I understand your question correctly, what you want to enable is Descending ordering by default (True -> False) rather than Ascending (False -> True) ordering whenever you click the sorting buttons in your table.

How to do it? If you created your screens using scaffolding (dragging and dropping your entity to a flow in your application), an OnSort action should be created automatically and added as a callback for your table's On Sort event. To this action, you would have to make a couple changes, to the if and the assignments such that it looks like the following:


If you created the dynamic sorting manually, you can also adjust your own On Sort callback action so that it resembles this initial idea. Basically this makes the default ordering be Descending rather than Ascending.

Hopefully this solves your problem, I am attaching a sample OML as reference.

TrueFalseSorting.oml

Hi Kristina,

Could you please try this? I have made this change into the aggregate sorting parameter. Just for your information this change would be visible on the screen.

If(TableSort="","{Questionnaire}.[Question1] desc, {Questionnaire}.[Question2] Desc",TableSort)

Thanks & Kind Regards,

Sachin

Sorry, this actually threw me a server error, but I'm not sure why.

Solution

If I understand your question correctly, what you want to enable is Descending ordering by default (True -> False) rather than Ascending (False -> True) ordering whenever you click the sorting buttons in your table.

How to do it? If you created your screens using scaffolding (dragging and dropping your entity to a flow in your application), an OnSort action should be created automatically and added as a callback for your table's On Sort event. To this action, you would have to make a couple changes, to the if and the assignments such that it looks like the following:


If you created the dynamic sorting manually, you can also adjust your own On Sort callback action so that it resembles this initial idea. Basically this makes the default ordering be Descending rather than Ascending.

Hopefully this solves your problem, I am attaching a sample OML as reference.

TrueFalseSorting.oml

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