Consultor Eletrônico



Kbase 20995: ADM2. How to Programatically Assign Operator in SmartFilter
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   16/10/2008
Status: Unverified

GOAL:

How to Programatically Assign Operator in SmartFilter

FACT(s) (Environment):

Progress 9.X

CAUSE:

When using 'Explicit' Style in the Instance Properties of the filter, the user is able to select an operator from either a combo-box or a radio-set.
The operator is only modifiable via user intervention.  However, the developer may have a business rule that requires them to initialize a certain operator for specific fields or data-types.

FIX:

This Solution offers a way to either customize filtercustom.p, or write a local procedure in the filter container to accomplish this.

The code below assumes a container in which a filter has been dropped.
DEFINE VARIABLE cOperatorHandles AS CHARACTER NO-UNDO.
DEFINE VARIABLE cFieldHandles    AS CHARACTER NO-UNDO.

DEFINE VARIABLE hOperator        AS HANDLE    NO-UNDO.
DEFINE VARIABLE hField           AS HANDLE    NO-UNDO.
DEFINE VARIABLE hProp            AS HANDLE    NO-UNDO.

DEFINE VARIABLE iEntry           AS INTEGER   NO-UNDO.

ASSIGN /* First get the handle to the ADMProps buffer object */
      hProp = WIDGET-HANDLE(ENTRY(1,h_dynfilter:ADM-DATA,CHR(1)))
      
      /* Get the handle to the OperatorHandles field in the
         ADMProps buffer */
      hOperator = hProp:BUFFER-FIELD('OperatorHandles':U)

      /* Get the handle to the FieldHandles field in the
         ADMProps buffer */
      hField = hProp:BUFFER-FIELD('FieldHandles':U)

      /* Retrieve the comma separated list of operator handles.
         This will match the number of entries in the FieldHandles
         Field */
      cOperatorHandles = hOperator:BUFFER-VALUE

      /* Retrieve the comma separated list of field handles */
      cFieldHandles = hField:BUFFER-VALUE NO-ERROR.
 
 DO iEntry = 1 TO NUM-ENTRIES(cOperatorHandles):

   /* Reuse the hOperator and hField variables to get the handle of
      each individual operator and field in the list */
   ASSIGN hOperator = WIDGET-HANDLE(ENTRY(iEntry,cOperatorHandles))
          hField    = WIDGET-HANDLE(ENTRY(iEntry,cFieldHandles))
      NO-ERROR.

   /* Both the Radio-Set and the Combo-Box use List-Item-Pairs,
      the actual SCREEN-VALUE MUST be assigned an operator symbol
      rather than what is actually displayed on the screen.

      for example, In the combo box, the value displayed for '>=' is
          'Greater Equals' but the list-item is actually '>=' */

   IF CAN-DO('INTEGER,DECIMAL,DATE':U,hField:DATA-TYPE) THEN
     hOperator:SCREEN-VALUE = '>=':U NO-ERROR.

   IF hField:DATA-TYPE = 'CHARACTER':U THEN
     hOperator:SCREEN-VALUE = '=':U NO-ERROR.
 END.