Forum Post: RE: ADM2 - Sort SmartBrowse by Calculated Field

  • Thread starter Thread starter Håvard Danielsen
  • Start date Start date
Status
Not open for further replies.
H

Håvard Danielsen

Guest
Some more info: This is only tested in a dynamic browse. 1. The ColumnsSortable property in the browse must be set to true (default is false) before it is initialized to utilize the adm2 sort support. 2. The SDO must be set up to not batch, (BatchSize= 0 - this is not default) to be able to sort on calculated fields. 3. It is also necessary to override the browser showSort to make the sort marker show up. This can be done in a custom browser class or directly in the dynamic adm2/dynbrowser.w rendering procedure. (keep your own version in an adm2 directory of your own ) as follows: function showSort returns logical ( /* parameter-definitions */ ): /*------------------------------------------------------------------------------ Purpose: Notes: ------------------------------------------------------------------------------*/ define variable lok as logical no-undo. define variable hDataSource as handle no-undo. define variable cSort as character no-undo. define variable cSortColumn as character no-undo. define variable lDesc as logical no-undo. define variable hColumn as handle no-undo. define variable iColumn as integer no-undo. define variable cFields as character no-undo. define variable cHandles as character no-undo. lok = super( ). if not lok then do: {get DataObjectHandle hDataSource}. if valid-handle(hDataSource) then do: {get QuerySort cSort hDataSource}. if cSort "" then do on error undo, throw: {get DisplayedFields cFields}. {get FieldHandles cHandles}. assign cSortColumn = entry(1,cSort,'':U) entry(1,cSort,'':U) = '':U lDesc = left-trim(cSort + ' ':U) begins 'DESCENDING ':U iColumn = lookup(cSortColumn,cFields) hColumn = widget-handle(entry(iColumn,cHandles)) hColumn:sort-ascending = not lDesc. catch e as Progress.Lang.Error : /* error handling here */ end catch. end. end. end. end function.

Continue reading...
 
Status
Not open for further replies.
Back
Top