Sort asc and desc on alternate clicks of a button

Hello there

I have a simple list of items with buttons at the head of each column with methods attached so you can sort by that particular column. Not being a whizz at Servoy just yet, I would like to know how to have it sort the column in ascending and descending order on alternate clicks of said buttons. Is this possible?

Any help much appreciated.

Thanks

Look in the Servoy menus for the sort command. In the dialog box there is a button to “Copy” the sort string.

Create a script. Add a controller.sort() and paste in the sort string. I think it needs quotes.

You will need one to sort ASC and one DESC…

Many thanks for your reply. Once I’ve created the scripts, how do I apply them to the button so it sorts asc/desc on alternate clicks?

You could set up a Global field gColSort then:

if (gColSort)
{
sort ‘fieldname asc’
gColSort = null
}
else
{
sort ‘fieldname desc’
gColSort = 1
}

Warning: pseudo code as haven’t got Servoy open but should get you started

Graham Greensall
Worxinfo Ltd