It gets complicated ...
Creating the dialog with the folders and xbrowse:
- Code: Select all Expand view
DEFINE DIALOG oSIdlg RESOURCE "STOCKINw" BRUSH oBrush transparent OF oWnd
// Install two folders
REDEFINE FOLDEREX oFldSI ID 800 OF oSIdlg PROMPT "&Stocking Items", "&Totals" DIALOGS "STOCKINaw", "STOCKINbw" ;
ON CHANGE oLbx1:setfocus() ROUND 5 TRANSPARENT // ON CHANGE
// Create the browse
REDEFINE XBROWSE oLbx1 ;
DATASOURCE oStkSrv:aStkPar ;
HEADERS " Part ", " Description ", " Ordered ", " Received ", " Cost ", " Workorder ", " " ;
COLUMNS 3, 8, 6, 14, 12, 10, " " ;
ID 7802 OF oSIdlg ;
ON CHANGE ( oFldSI:adialogs[1]:update( ), oLbx1:setfocus() ) UPDATE
// Provide the header gradient
oLbx1:bClrGrad := aPubGrad
// Set the styles
oLbx1:nMarqueeStyle := MARQSTYLE_HIGHLROW
oLbx1:nColDividerStyle := LINESTYLE_RAISED
oLbx1:nRowDividerStyle := LINESTYLE_RAISED
oLbx1:nHeadStrAligns := AL_CENTER
oLbx1:nStretchCol := STRETCHCOL_LAST
This field is used to store the value that is modified. It is in the dialog on folder 1
- Code: Select all Expand view
REDEFINE GET oStkSrv:aStkPar[oLbx1:nArrayAt,12] PICTURE "$99,999.9999" ID 823 OF oFldSI:aDialogs[1] ;
MESSAGE "The actual cost paid per item" UPDATE
This is a "Save" button which actually refreshes the display of the xbrowse with the new value.
- Code: Select all Expand view
DEFINE BUTTON OF oBarStk RESOURCE "HRSAVE" PROMPT "Save" TOOLTIP "Save part" ;
ACTION ( oLbx1:update(), ::SumStock( ), oLbx1:setfocus( ) ) ;
MESSAGE "Save the data for the highlighted part"
Here is why it is complicated:oStkSrv is an object of the Purchase Order class
aStkPar is a DATA element of that class which contains the editable elements of the existing order. It is created from a DBF with just the records pertaining to the selected purchase order. After the editing is performed, then a separate method is used to save the array elements back to the database.
::SumStock is a method of the same class that simply multiplies the quantity received * the cost for a total. That total is stored in a memory variable.
A couple of other points.
oFldSI:aDialogs[1] contains the GET fields for the array elements
The
oLbx1 xbrowse is attached to the Dialog, not the folders.