Consultor Eletrônico



Kbase P122669: How to switch a dynamic ADM2 smartDataBrowser between different SmartDataObjects
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   07/03/2007
Status: Unverified

GOAL:

How to switch a dynamic ADM2 smartDataBrowser between different SmartDataObjects

GOAL:

How to change the datasource of a dynamic smartDataBrowse.

FIX:

To achieve this you need to do the following:

1. Remove any existing links between the smartDataBrowse and SDO.
2. Add the new link from the new SDO.
3. Set the browse displayedFields property to a list of fields to display.
4. Associate the browse query with the SDO query.
5. Run initializeObject in the browse.
6. Open the new SDO query.

For example, the following is example code to achieve this. The code is from a smartWindow that contains a single smatDataBrowse, two smartDataObjects and two buttons to switch the browse between the objects.


/* Definitiaons section Local Variable Definitions --- */
DEFINE VARIABLE h_custSDO AS HANDLE NO-UNDO.
DEFINE VARIABLE h_orderSDO AS HANDLE NO-UNDO.
DEFINE VARIABLE h_SDB AS HANDLE NO-UNDO.
DEFINE VARIABLE h_browse AS HANDLE NO-UNDO.


PROCEDURE initializeObject :
/*------------------------------------------------------------------------------
Purpose: Super Override
Parameters:
Notes:
------------------------------------------------------------------------------*/
/* Code placed here will execute PRIOR to standard behavior. */
RUN SUPER.
/* Code placed here will execute AFTER standard behavior. */

DEFINE VARIABLE cTargets AS CHARACTER NO-UNDO.
EFINE VARIABLE i AS INTEGER NO-UNDO.
DEFINE VARIABLE h_object AS HANDLE NO-UNDO.
DEFINE VARIABLE cType AS CHARACTER NO-UNDO.

{get ContainerTarget cTargets TARGET-PROCEDURE}.

/* get object handles at startup */
DO i = 1 TO NUM-ENTRIES(cTargets):
h_object = WIDGET-HANDLE(ENTRY(i,cTargets)).
cType = DYNAMIC-FUNCTION('getObjectType':U IN h_object).

IF h_object:FILENAME = "test_sdo/dcustumer_order.w" THEN
h_custSDO = h_object.
IF h_object:FILENAME = "test_sdo/dorder_custumer.w" THEN
h_orderSDO = h_object.
IF h_object:FILENAME = "adm2/dynbrowser.w" THEN
h_SDB = h_object.
END.
{get browsehandle h_browse h_SDB}.
END PROCEDURE.


/* Customer SDO button trigger code */
ON CHOOSE OF BUTTON-3 IN FRAME fMain /* customer */
DO:
DEFINE VARIABLE cFields AS CHARACTER NO-UNDO.
DEFINE VARIABLE h_query AS HANDLE NO-UNDO.
cFields = "custnum,name".
RUN removeLink( h_orderSDO, 'Data':U , h_SDB) NO-ERROR.
RUN addLink ( h_custSDO, 'Data':U , h_SDB) NO-ERROR.
h_query = DYNAMIC-FUNCTION('getqueryHandle':U IN h_custSDO).
h_browse:QUERY = h_query.
{set DISPlayedFields cFields h_SDB}.
{set DataQueryBrowsed FALSE h_custSDO}.
RUN initializeObject IN h_sdb.
DYNAMIC-FUNCTION('openQuery':U IN h_custSDO).
END.

/* Order SDO button trigger code */
ON CHOOSE OF BUTTON-4 IN FRAME fMain /* Order */
DO:
DEFINE VARIABLE cFields AS CHARACTER NO-UNDO.
DEFINE VARIABLE h_query AS HANDLE NO-UNDO.
cFields = "ordernum,name".
RUN removeLink( h_custSDO, 'Data':U , h_SDB) NO-ERROR.
RUN addLink ( h_orderSDO, 'Data':U , h_SDB) NO-ERROR.
h_query = DYNAMIC-FUNCTION('getqueryHandle':U IN h_orderSDO).
h_browse:QUERY = h_query.
{set DISPlayedFields cFields h_SDB}.
{set DataQueryBrowsed FALSE h_orderSDO}.
RUN initializeObject IN h_sdb.
DYNAMIC-FUNCTION('openQuery':U IN h_orderSDO).
END.