Sorting grid by calculated variable in my Find/Browse

benigno1985

Member
Hi, everyone how to sort a grid by a variable when I read my grid in Find/Browse.
while I calculte the variable in my SENTENCE WHILE if I finish
now I want to sort the data in descending order by variable.

 
The short answer is: you can't. However, there are techniques that allow for this. The default 'Find' button logic doesn't allow for sorting on any column that is not part of the business view. Here are a couple of options to consider:

1) SQL View (search this forum for that term and you will find many threads pertaining to this subject). If your calculation field can be achieved in a SQL statement, this option may be your easiest to implement and provide the best performance.

2) Make it a 2-stage process... suppress the 'Find' button logic and build a workfile that will hold the data you will display in the grid. The workfile will have the calculated value and your business view will be over the workfile instead of your primary file. The requires you to manually (using system functions) insert records into the grid.

Maybe other posters will have some other creative ideas.
Good luck.
 
Jeremy

Thank you very much for your assistance. Let me check the solutions.

Regards.
Benigno
 
Jeremy's idea is very similar to a way I have solved this before

I was asked to find a way of making sure spilt lines appeared in a correct order after being added at the end of the grid. I did this by SEQN and LNID

Here's how I did it:

Basically, have a workfile to save off the GC records by looping through the already populated Grid.
Save ALL fields. Audit fields, everything.
Delete the GC file records before 're insertion'

Then select the Workfile on an index with an ascending LNID/SEQN. (or whatever field you wish to sequence by)
As you loop through, just re insert the GC table records but with an incremented count for the SEQN/LNID
This ensures a newly resequenced GC table
 
Back
Top