Kbase P81151: How to delete "Add" node popup menu in a TreeView depending on the value of the record fields corres
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  16/10/2008 |
|
Status: Unverified
GOAL:
How to delete "Add" node popup menu in a TreeView depending on the value of the record fields corresponding to the selected node?
FACT(s) (Environment):
Dynamics 2.1A
FIX:
The below example verifies if the value of the database salesrep_code field is equal with "AAA" and if it is then it deletes the Add Node popup menu. This logical condition is placed in the tvNodeSelected procedure (see below), and should be replaced by your own logical condition, eventually by a function call on the SDO which returns TRUE or FALSE, depending on the current record - this can make the TreeView custom super procedure reusable.
Add and edit the the TreeView custom super procedure:
1. In the definition block define the variable:
DEFINE VARIABLE glPopup AS LOGICAL NO-UNDO.
2. Add the folowing internal procedure:
PROCEDURE tvNodeSelected:
/*------------------------------------------------------------------------------
Purpose:
Parameters:
Notes:
------------------------------------------------------------------------------*/
DEFINE INPUT PARAMETER pcNodeKey AS CHARACTER NO-UNDO.
DEFINE VARIABLE hTreeBuffer AS HANDLE NO-UNDO.
DEFINE VARIABLE hData AS HANDLE NO-UNDO.
DEFINE VARIABLE cc AS CHARACTER NO-UNDO.
RUN returnTreeBuffer IN TARGET-PROCEDURE (INPUT pcNodeKey, OUTPUT
hTreeBuffer).
hData =
IF hTreeBuffer:AVAILABLE THEN
hTreeBuffer:BUFFER-FIELD("sdo_handle":U):BUFFER-VALUE
ELSE ?.
RUN SUPER(pcNodeKey).
cc = {fnarg columnValue 'salesrep_code' hData} NO-ERROR.
/*I don't want to display the popup menu for records with salesrep_code = "AAA":*/
glpopup = cc <> "AAA".
END PROCEDURE.
3. Add the following internal procedure in the TreeView custom super procedure :
PROCEDURE BuildPopupMenu
/*------------------------------------------------------------------------------
Purpose:
Parameters:
Notes:
------------------------------------------------------------------------------*/
DEFINE INPUT PARAMETER pdNodeObj AS DECIMAL NO-UNDO.
DEFINE INPUT PARAMETER pcNodeKey AS CHARACTER NO-UNDO.
DEFINE VARIABLE hPopupMenu AS HANDLE NO-UNDO.
DEFINE VARIABLE hWindow AS HANDLE NO-UNDO.
{get ContainerHandle hWindow}.
IF glPopup THEN
RUN SUPER (pdNodeObj, pcNodeKey).
ELSE DO:
DELETE WIDGET-POOL ("WidgetPool" + STRING(TARGET-PROCEDURE)) NO-ERROR.
CREATE WIDGET-POOL ("WidgetPool" + STRING(TARGET-PROCEDURE)) PERSISTENT NO-ERROR.
ASSIGN hPopupMenu = hWindow:POPUP-MENU.
IF VALID-HANDLE( hPopupMenu ) THEN
DELETE WIDGET hPopupMenu.
hWindow:POPUP-MENU = ?.
DELETE WIDGET-POOL ("WidgetPool" + STRING(TARGET-PROCEDURE)) NO-ERROR.
END.
END PROCEDURE.