Consultor Eletrônico



Kbase P27356: How to disable/enable the 'Update' and 'Delete' buttons of a SmartToolbar depending on the value of
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   10/15/2008
Status: Verified

GOAL:

How to disable/enable the 'Update' and 'Delete' buttons of a SmartToolbar depending on the value of SmartDataViewer field?

FACT(s) (Environment):

Windows
Progress 9.1x

FIX:

To disable/enable the 'Update' and 'Delete' buttons of a SmartToolbar depending on the value of a specific SmartDataViewer field use the 'modifyDisabledActions', 'disableActions' and 'enableActions' functions in an override of displayFields procedure of the SmartDataViewer.

The code below demonstrates this solution using the value of the Country field of a Customer table based SmartDataViewer object:

PROCEDURE displayFields :
/*------------------------------------------------------------------------------
 Purpose:     Super Override
 Parameters:  
 Notes: This override demonstrates how to disable/enable the 'Update'
and 'Delete' buttons of the SmartToolbar depending on the
value of the 'Country' field in the Customer Smart Data Viewer.
------------------------------------------------------------------------------*/
   DEFINE INPUT PARAMETER pcColValues AS CHARACTER NO-UNDO.

   /* Code placed here will execute PRIOR to standard behavior. */

   RUN SUPER( INPUT pcColValues).

   /* Code placed here will execute AFTER standard behavior.    */

   DEFINE VARIABLE iLoop          AS INTEGER   NO-UNDO.
   DEFINE VARIABLE iNumEntries    AS INTEGER   NO-UNDO.
   DEFINE VARIABLE hField         AS HANDLE    NO-UNDO.
   DEFINE VARIABLE cFieldHandles  AS CHARACTER NO-UNDO.
   DEFINE VARIABLE hTableioSource AS HANDLE    NO-UNDO.

   ASSIGN cFieldHandles = DYNAMIC-FUNCTION('getAllFieldHandles')
       iNumEntries    = NUM-ENTRIES(cFieldHandles)
        hTableioSource = DYNAMIC-FUNCTION('getTableIOSource').
   
   DO iLoop = 1 TO iNumEntries:
       ASSIGN hField = WIDGET-HANDLE(ENTRY(iLoop,cFieldHandles)).
       IF hField:NAME = "COUNTRY" AND hField:SCREEN-VALUE = "USA" THEN
DO:
            DYNAMIC-FUNCTION('modifyDisabledActions' IN hTableioSource, "ADD", "Update,Delete").
           DYNAMIC-FUNCTION('disableActions' IN hTableioSource, "Update,Delete").
       END.
       ELSE
DO:
           DYNAMIC-FUNCTION('modifyDisabledActions' IN hTableioSource, "REMOVE", "Update,Delete").
           DYNAMIC-FUNCTION('enableActions' IN hTableioSource, "Update,Delete").
END.
END.
END PROCEDURE.