Stupid Smart Filter

sidero

New Member
Hi everyone, I'm a bit frustrated...

I would like to set the default values of the search fields in a smart fields, and to my suprise, I found out that Progress does not support this directly! I then referred to Kbase Id 2058 that explanes how to adapt CustomFilter.p/.i to do this.
HOWEVER my fields seem to be set to FORMAT "x" and the Filter doesn't work at all, even when I press the reset button, which actually should display all my records.

further this a note in kBase 20258:
2) Keep in mind that assigning the SCREEN-VALUE of hField may truncate
your data if the FORMAT of hField is too small.
To solve this problem, you may then do hField:FORMAT = FILL('X',
repeats) or at least check the lenght of the FORMAT before setting the
SCREEN-VALUE attribute.

....what !!!??? It is NOT possible to get the handle of the search fields! I tried {get FieldHandles lFieldHandles h_dynfilter}, seems to be a pPrivate function only.

Can someone enlighten me on this problem. Has perhaps anyone
built a better custom smart filter?

Thanks in advance for any help/comments given
Oliver
 
S

sidero

Guest
Stupid Smart Filter:Setting initial values

well here is the Solution:

IN LocalInitialize after RUN SUPER:

{get enabledFields lEnabledFields h_dynfilter}.
{get FieldHandles lFieldHandles h_dynfilter}.

DO i = 1 TO NUM-ENTRIES(lFieldHandles,","):
lHndl = WIDGET-HANDLE(ENTRY(i,lFieldHandles,",")).
IF VALID-HANDLE(lHndl) AND LOOKUP(lHndl:NAME,lEnabledFields,",") <> 0 THEN DO:
cColumnFormat = DYNAMIC-FUNCTION('ColumnFormat':U IN h_dynFilter,lHndl:NAME).
ASSIGN lHndl:FORMAT = cColumnFormat.
CASE lHndl:NAME:
WHEN "{&FieldName-1}":U THEN DO:
ASSIGN lHndl:SCREEN-VAL = gp{&FieldName-1}.
END.
WHEN "{&FieldName-2}":U THEN DO:
ASSIGN lHndl:SCREEN-VAL = gp{&FieldName-2}.
END.
END CASE.
END.
END.
RUN ApplyFilter IN h_dynfilter.

you will however need to customize filtercustom.p as follows:
FUNCTION getFieldHandles RETURNS CHARACTER
( /* parameter-definitions */ ) :
/*------------------------------------------------------------------------------
Purpose: make GetFieldHandles public
Notes:
------------------------------------------------------------------------------*/
DEF VAR lFieldHandles AS CHAR NO-UNDO.
{get FieldHandles lFieldHandles}.

RETURN lFieldHandles. /* Function return value. */

END FUNCTION.
 
Top