TDataRow

Fuente: source/classes/datarow.prg

Standalone class

TDataRow is a data-record editor that provides a convenient interface for viewing and editing individual records from a data source. It works with DBF work areas, ADO recordsets, arrays, and hashes, making it a versatile tool for record-level operations. TDataRow maintains an original copy of the data and can detect modifications.

Key DATA Members

DATATypeDescription
aDataArrayArray of current field values
aOrgArrayArray of original field values (for change detection)
aPromptsArrayArray of field prompt/label strings
uSourceVariantSource data: alias (N), ADO recordset, array, or hash
cSrcTypeCharacterSource type string: "DBF", "ADO", "ARR", or "HSH"
bSaveBlockCode block evaluated on successful save
bValidBlockCode block for record validation before save
bEditBlockCode block evaluated when edit begins

Methods

MethodDescription
New( uSource, cFieldList, lBlank, aInitVals )Create a data row from a source and optional field list
Load( lBlank )Load current values from the source into aData
Save( lCheck, lSilent )Write changes back to the source; optional validation
Edit( lReadOnly, lNavigate, cTitle, cMsg )Open a dialog for interactive record editing
Undo( fld )Revert a field to its original value
Copy()Create a copy of the current record data
Paste( hRec )Paste a previously copied record into the buffer
Modified( fld )Check if a field (or any field) has been modified
FieldGet( fld )Get a field value by name or position
FieldPut( fld, uVal )Set a field value by name or position

Example: Edit Current DBF Record

#include "FiveWin.ch"

function Main()

   local oDb, oRow

   DATABASE oDb FILE "customers.dbf" DRIVER "DBFCDX" SHARED

   oDb:GoTop()

   // Create a data row for the current record
   oRow := TDataRow():New( oDb:nArea )

   // Open the edit dialog
   if oRow:Edit( , , "Edit Customer" )
      // User pressed OK -- changes are saved automatically
      MsgInfo( "Record saved" )
   else
      MsgInfo( "Edit cancelled" )
   endif

   oDb:Close()

return nil

Notes

Ver También