Kbase P90523: How to delete a record from a SmartDataBrowse and add it to another on double click of a button?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  10/26/2004 |
|
Status: Unverified
GOAL:
How to delete a record from a SmartDataBrowse and add it to another on double click of a button?
FACT(s) (Environment):
Windows
Progress 9.x
OpenEdge 10.x
FIX:
1. Create an SDO against the Employee table.
2. Create an SDO against a temp table defined LIKE the Employee table.
3. Define a SmartDataBrowse against the dEmployee.w SDO.
4. Create a SmartDataBrowse against the dttEmployee.w SDO.
5. Create a Window to contain all the above and a Button.
6. Define the following two variables in the main windows definition section to store the handles of the two browsers.
DEFINE VARIABLE hSourceBrowse AS HANDLE NO-UNDO.
DEFINE VARIABLE hTargetBrowse AS HANDLE NO-UNDO.
7. Behind the main window's button insert the following code:
DEFINE VARIABLE hSourceSDO AS HANDLE NO-UNDO.
DEFINE VARIABLE hTargetSDO AS HANDLE NO-UNDO.
ASSIGN
hSourceSDO = DYNAMIC-FUNCTION('getDataSource':U IN hSourceBrowse)
hTargetSDO = DYNAMIC-FUNCTION('getDataSource':U IN hTargetBrowse).
RUN CreateRecord IN hTargetSDO (INPUT hSourceSDO).
RUN DeleteRow IN hSourceBrowse.
8. In the main window define a procedure GetSourceBrowse to grab the handle of the source browse (bEmployee):
DEFINE INPUT PARAMETER phSource AS HANDLE NO-UNDO.
ASSIGN
hSourceBrowse = phSource.
END PROCEDURE.
9 Create an initialize object override in the SourceBrowse Object to pass the handle to the main window by running the GetSourceBrowse procedure defined in step 8:
/* Let the main window know you are the SourceBrowse handle */
RUN SUPER.
DEFINE VARIABLE hContainerSource AS HANDLE NO-UNDO.
ASSIGN
hContainerSource = DYNAMIC-FUNCTION('getContainerSource':U) NO-ERROR.
RUN GetSourceBrowse IN hContainerSource (THIS-PROCEDURE) NO-ERROR.
10. In the main window define a procedure to grab the handle of the Target
browse (bttEmployee):
DEFINE INPUT PARAMETER phSource AS HANDLE NO-UNDO.
ASSIGN
hTargetBrowse = phSource.
END PROCEDURE.
11. Create an initialize object override in the TargetBrowse Object to pass the
handle to the main window by running the GetTargetBrowse procedure defined in
step 8:
/* Let the main window know you are the Target Browse handle */
RUN SUPER.
DEFINE VARIABLE hContainerSource AS HANDLE NO-UNDO.
ASSIGN
hContainerSource = DYNAMIC-FUNCTION('getContainerSource':U) NO-ERROR.
RUN GetTargetBrowse IN hContainerSource (THIS-PROCEDURE) NO-ERROR.
12. In the source Browse create the following DeleteRow procedure that will
delete each row after we copy it to the newly created ttEmployee record:
DEFINE VARIABLE hSourceSDO AS HANDLE NO-UNDO.
DEFINE VARIABLE cRowIdent AS CHARACTER NO-UNDO.
ASSIGN
hSourceSDO = DYNAMIC-FUNCTION('getDataSource':U)
cRowIdent = DYNAMIC-FUNCTION('getRowident' IN hSourceSDO).
DYNAMIC-FUNCTION('fetchrowident' IN hSourceSDO, cRowIdent, "").
ASSIGN
cRowIdent = ENTRY(1, DYNAMIC-FUNCTION('colValues' IN hSourceSDO,""),
CHR(1)).
DYNAMIC-FUNCTION('DeleteRow' IN hSourceSDO, cRowIdent).
13. In the target SDO (dttEmployee ) define a CreateRecord procedure that will
copy the currently selected row in the Source Browse:
DEFINE INPUT PARAMETER hSourceSDO AS HANDLE NO-UNDO.
DEFINE VARIABLE cRowident AS CHARACTER NO-UNDO.
CREATE ttEmployee.
cRowident = DYNAMIC-FUNCTION('getRowident':U IN hSourceSDO).
FIND FIRST Employee WHERE ROWID(Employee) = TO-ROWID( cRowident ).
BUFFER-COPY Employee TO ttEmployee.
DYNAMIC-FUNCTION('openQuery':U).