Kbase 20258: SmartFilter: How to Set Default Values
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  1/24/2005 |
|
Status: Verified
GOAL:
How to set the default value for a Progress SmartFilter.
FIX:
The following code demonstrates how to set the default value for a SmartFilter. Ideally the code should be added to adm2/custom/filtercustom.p (this requires that the start-super-proc in src/adm2/custom/filtercustom.i is uncommented), but it is possible to have the code in a local adm2/dynfilter.p.
Function assignColumnScreenValue
RETURNS LOGICAL
(pcColumn AS CHAR,
pcValue AS CHAR):
DEFINE VARIABLE cFields AS CHAR NO-UNDO.
DEFINE VARIABLE cFieldHdls AS CHAR NO-UNDO.
DEFINE VARIABLE cToFieldHdls AS CHAR NO-UNDO.
DEFINE VARIABLE iField AS INT NO-UNDO.
DEFINE VARIABLE hField AS HANDLE NO-UNDO.
{get DisplayedFields cFields}.
iField = LOOKUP(pcColumn,cFields).
IF iField > 0 THEN
DO:
{get FieldHandles cFieldHdls}.
hField = WIDGET-HANDLE(ENTRY(iField,cFieldHdls)).
hField:SCREEN-VALUE = pcValue.
/* if range we also set the TO value */
IF {fnarg columnOperatorStyle pccolumn} = 'Range':U THEN
DO:
{get cOperatorHandles cToFieldHdls}.
hField = WIDGET-HANDLE(ENTRY(iField,cToFieldHdls)).
hField:SCREEN-VALUE = pcValue.
END.
END.
RETURN TRUE.
END FUNCTION.
The following code can be used in an initializeObject override in the container after the RUN SUPER statement:
RUN SUPER.
DYNAMIC-FUNCTION('assignColumnScreenValue' IN h_dynfilter,'custnum',
6).
There is a potential conflict here because the SmartFilter always displays all values that have been added to the query with assignQuerySelection.