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

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

Håvard Danielsen

Guest
The ADM2 can have calculated fields in the SmartBrowse or in the SDO. I don't think it is possible to sort on a calculated field defined in the SmartBrowse as it is is generated as an expression in the browse's DISPLAY statement. Unfortunately, it is not supported to sort on a calculated field in the SDO either. This is addressed in issue PSC00261588, which currently is not scheduled. You may call Support and let them know that you need/want this fixed, but be aware that one of the reasons this has not been fixed is that it is very unlikely that we could make it work nicely/seamlessly when batching. But we could fix the SDO to support sort on calculated fields when all the data is on the client. There are many ways to fix this with code, the simplest is probably to override newQuerySort in the SDO and override the last parameter before the call to super to force it to make the sort local when there is a calculated field as follows. function newQuerySort returns character ( input pcQuery as character, input pcSort as character, input plDBColumns as logical ): /*------------------------------------------------------------------------------ Purpose: Notes: ------------------------------------------------------------------------------*/ /* This example checks for the calculated column name. This may not be necessary, but there could be some issues if you use a filter or some other action that needs a new server request since the last sort passed through here may be passed to server and it may not be valid on server. So it may be best to limit this to the case that absolutely need it. (this is a theoretical issue and only if your local field has a different name than the db field) */ if plDbColumns = true and pcSort begins "Rowobject.calc " /* Ensure that all data is in the SDO. Cannot sort local if we are batching, cannot sort on calc if we are batching */ and dynamic-function("isDataQueryComplete") then plDbColumns = false. return super( input pcQuery, input pcSort, input plDBColumns ). end function.

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