Forgive me if this has been discussed before but I tried to search on it without success!
I’d like a table view to allow a multi-column sort. Just like in Access where I can select adjacent columns and sort on them all at one time, column 1 first then column 2 etc.
Also where I can select 1 column - sort on it, then another column and sort on it keeping the sort from the first column - therefore multicolumn sort is respected.
Is this possible in Servoy - out of the box or through some coding solution?
Jan Aleman:
Can you explain step by step what you want to do?
Thanks for taking the time Jan… Sorry it appears that I set the title of this thread to ‘Search’ accidentally rather than the ‘Sort’ I wanted!
User has a table on screen, and he wants to sort on multiple columns simultaneously. In Servoy it seems that when I click on a column head - that column is sorted immediately. The next column clicked sorts the table again without taking account of the previous sort. In Access a CTRL-Click on the specific columns (which selects and highlights the columns either adjacent or not) allows a sort using all selected columns, in a left - right column format.
I suspect there will be a method I could use to code the sort (as you suggested Jan) but I don’t know how I could a. select the columns without actually sorting them immediately, or b. determine which columns were selected ready to sort.
Just hook your code to the onSort event of the form, it will overrule the default behaviour. ctrl-click to select columns is also possible by changing the background color of the column on detection of the ctrl-key (ctrl-key detection works smart client only as far as I know)
Jan Aleman:
Just hook your code to the onSort event of the form, it will overrule the default behaviour. ctrl-click to select columns is also possible by changing the background color of the column on detection of the ctrl-key (ctrl-key detection works smart client only as far as I know)
Thanks Jan - I’ll take a look into that CTL-Key selection thing. There are some aspects of the app I’m happy to work better in the Smart Client.
Below is a global idea to get you started. It contains a few bugs but hey it’s sunday afternoon and I wrote it below 10 minutes. It assumes the names of your view are the same as the columnnames.
*/
function sort()
{
var colname = arguments[0]
var m = application.getLastKeyModifiers()
if(m&1){
if (elements[colname].bgcolor == '#aa0000') {
elements[colname].bgcolor = null
utils.stringReplace(globals.sortstring,globals.sortstring+',','')
}
else {
elements[colname].bgcolor = '#aa0000'
globals.sortstring = globals.sortstring + ',' +colname
}
}
else{
controller.sort(globals.sortstring.substring(2))
}
}