Topic: Sort By Hidden Column

Hi All,
Some assistance if anyone has a bit of time please and I attach a simple dummy project to demonstrate the problem.
1. 
I have a table ('people') with 3 fields
     - 'firstname'
     - 'lastname'.
     - calculated field ('firstname' + 'lastname').
2. 
In the tablegrid, I only want to show one column (the 'calculated field') but it needs to be sorted by 'lastname'.  So I add a second column ('lastname') but make it invisible.
3.
By clicking on Column0 header ('calculated field'), I am trying to force (by script) the tablegrid to sort (ascending / descending) by the hidden Column1 ('lastname').and not by Column0 (the 'calculated field').
4.
But so far, I've been unable to find a way to do this and no matter what I've tried, it always sorts by Column0.
If anyone has any ideas or suggestions, I'd be grateful.
Thanks,
Derek.

Post's attachments

Attachment icon sort by hidden column.zip 446.15 kb, 79 downloads since 2024-08-30 

Re: Sort By Hidden Column

Hello Derek
Can this links give you some clues :

https://www.codeproject.com/Questions/1 … -in-delphi
and
https://supportcenter.devexpress.com/ti … rm-sorting

by adapting them to the MVD syntax?
Cordially
JB

Re: Sort By Hidden Column

Hi Derek


Your project works with a database from another directory. Please rebuild.

Re: Sort By Hidden Column

Hi Sparrow,
Sorry about that - I use my 'template' (play) application for lots of other things and forgot I'd set it like that.
Should be okay now.
Thanks,,
Derek

Post's attachments

Attachment icon sort by hidden column1.zip 446.61 kb, 77 downloads since 2024-08-30 

Re: Sort By Hidden Column

Just to clarify, the screen capture shows the current and desired sort sequence (ascending) and the current desired sort sequence (descending).
Thanks,
Derek.

Post's attachments

Attachment icon sort problem.jpg 25.31 kb, 45 downloads since 2024-08-30 

Re: Sort By Hidden Column

I removed the sorting in the table, in the search button.
The rest of the changes are in the script.

Post's attachments

Attachment icon sort by hidden column1 m.zip 445.28 kb, 76 downloads since 2024-08-30 

Re: Sort By Hidden Column

Hi Sparrow, Jean,
That's genius Sparrow - works perfectly.
Setting Col0 options to '-cocansort' seems counter-intuitive at first but now I see why it has to be that way.
The only addition I've made is to change the Column0 header caption to be 'FULL NAME ▼' or 'FULL NAME ▲' but that's simply cosmetic.
Merci pour les liens Jean - I was reading through the examples (and struggling to understand it  big_smile) when Sparrow uploaded his solution.
Thanks to both of you as always for your help,
Regards,
Derek.

Re: Sort By Hidden Column

Good morning Derek, Jean


Setting the Col0 parameter to "-cocansort" is mandatory. Otherwise, our sorting is triggered first and then the project does its sorting.
All this happens so quickly that it seems that our sorting does not work.


Derek, I suggest simplifying it further and removing the double output and table update at the start of the form.
We also remove the hidden column. The table is accessed via the search button for both search and output at start.
The "lastname asc" sorting is set in the properties of the search button.
The second column "lastname" is removed.
You can see the changes in the script yourself.


Best regards.
sparrow

Post's attachments

Attachment icon sort by hidden column2 m.zip 445.3 kb, 99 downloads since 2024-08-31 

Re: Sort By Hidden Column

Hi Sparrow, Jean,
Totally agree - using 'dbcustomorderby' removes the need for the hidden column, simplifies the whole approach and makes the script more compact.
Thanks for the improvements and your help,
Derek.