Browse Sort Header Get, Save, Restore, current settings

Hi All

In a browse that you have sort header on, How do you find the current setting for column(s) being sorted to save

and how do you apply saved settings back again?

No I mean if you have sort header enabled (Checkbox in std browse template) and the user clicks the header of a column to sort it.

I want to save that selection(s) and restore next time in.

Sean, I have the code but I need to dig it up. Give me a little while. It’s in client VM.

Posted in SV.Clarion11 - Re: Browse Sort Header Get, Save, Restore, current settings
On Thu, Feb 18 2021 2:46 am, Kelvin Chua

CLEAR(BRWFMT:Record)
BRWFMT:UserIDProcedureName = CLIP(GLO:User_id)&CLIP(AccPro:ProcedureName)
GET(BRWFORMAT,BRWFMT:ByUserIDProcedureName)
CheckGetFileError('BRWFORMAT','BrAcctChrt')
IF ~ERROR()
   BRWFMT:TabOrder = ?CurrentTab{Prop:ChoiceFEQ}
   PUT(BRWFORMAT)
ELSE
   CLEAR(BRWFMT:Record)
   BRWFMT:UserIDProcedureName = CLIP(GLO:User_id)&CLIP(AccPro:ProcedureName)
   BRWFMT:TabOrder = ?CurrentTab{Prop:ChoiceFEQ}
   ADD(BRWFORMAT)
.

The BRWFMT is the prefix of my table BrowseFormat.TPS

To Restore, at Window Init:

  CLEAR(BRWFMT:Record)
  BRWFMT:UserIDProcedureName = CLIP(GLO:User_id)&CLIP(AccPro:ProcedureName)
  GET(BRWFORMAT,BRWFMT:ByUserIDProcedureName)
  IF ~ERROR()
     IF BRWFMT:TabOrder <> 0
        ?CurrentTab{Prop:ChoiceFEQ} = BRWFMT:TabOrder
     .

Thanks Carl
But that seems to just save and restore the current Tab.

I want the Sort header

ie when you click the heading of the browse and it sorts on that column. Enabled from Std Browse Actions->Browse Box Behaviour->Extended Options-> Enable Sort Header

Sean, use the GetSortOrder() method to find out what column is being sorted on. You can save this to INI or wherever.
Use SetSetOrder(###) to set the initial sort order on the sort order class in the window init to set the initial sort order. Make sure this is after all the setup/init calls for the sort header class.

OK For reference. This ended up being way too easy.
Thanks @Rick_UpperPark for pointing me to the class, which had a save and restore method, which eventually led to the template. . .
Anyway there’s a simple checkbox to achieve this in the customise sort header area.

image

My usage is all in handcode, no Templates. So I just looked at the code. :grinning: