Table of Contents

TTMSFNCDataGridDatabaseAdapter Class

Non-visual component that binds a TDataSource to a TTMSFNCDataGrid. Drop it on a form alongside a grid, set DataGrid and DataSource, and the grid is automatically populated with dataset rows. Supports live sorting, filtering, grouping, inline editing, and master-detail layouts across VCL, FMX, and TMS WEB Core.

API unit family: TMSFNCDataGridDatabaseAdapter Inherits from: TTMSFNCCustomDataGridDatabaseAdapter

Syntax

TTMSFNCDataGridDatabaseAdapter = class(TTMSFNCCustomDataGridDatabaseAdapter)

Properties

Name Description
AutoCreateColumns When True (default), the adapter creates grid columns automatically from the dataset field list when a DataSource is assigned or the dataset becomes active. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
AutoRemoveColumns When True (default), auto-created columns are removed from the grid when the adapter's DataSource is cleared or the dataset becomes inactive. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
ColumnAtField Returns the adapter column item whose FieldName matches AFieldName, or nil when not found. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
Columns Collection of explicit field-to-column mappings. When empty and AutoCreateColumns is True, the adapter maps all visible dataset fields in field-list order. Populate this collection to control which fields appear, their column order, headers, and cell rendering. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
DataLink The internal TDataLink that connects this adapter to the TDataSource. Provides low-level access to the dataset link state. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
DataSource The TDataSource whose TDataSet is displayed in the grid. Assign this at design time or runtime to connect the adapter to a dataset. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
DetailControl Optional cell control embedded as a master-detail sub-grid. When set, expanding a grid row reveals the detail control inside the row's detail area. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
DynamicRecordCount When True, the adapter re-queries the dataset record count on every grid refresh instead of caching it. Useful for live datasets where the number of records changes frequently. Default is False. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
FieldAtColumn Returns the TField instance mapped to grid column AColumn, or nil when no field is mapped to that column. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
FieldIndexAtColumn Returns the dataset field-list index of the field mapped to grid column AColumn, or -1 when no field is mapped. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
FieldNames Gets or sets the field name mapped to adapter column AIndex. Setting this property updates the corresponding Columns[AIndex].FieldName value. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
HeaderRow The zero-based grid row index used for column headers. Default is 0. Change when the grid's fixed row layout places the header on a different row. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
KeepData When True, cell data loaded into the grid is kept in memory even after the dataset is closed or scrolled past. Useful for preserving unsaved edits across dataset navigation. Default is False. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
LoadMode Controls the record-loading strategy. almBuffered (default) loads only the records needed for the visible viewport. almAllRecords pre-loads all records into an in-memory cache, enabling full client-side sort and group operations. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
ShowBooleanFields When True (default), Boolean dataset fields are shown as check-box cells. Set to False to render Boolean values as their string representation. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
ShowDateTimeFields When True (default), date and time dataset fields are displayed using the locale date/time format. Set to False to suppress automatic date/time formatting. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
ShowMemoFields When True, memo/large-text dataset fields are shown in the grid. Default is False because memo fields can be very large; enable only when memo content must be visible. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
ShowPictureFields When True (default), BLOB/graphic dataset fields are rendered as embedded images. Set to False to hide picture fields or handle them via OnFieldToData. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
Version Component version string in Major.Minor.Release.Build format. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)

Methods

Name Description
AddAllFields Adds columns to the Columns collection for every field in the active dataset that is not already mapped. Equivalent to calling CreateColumns after clearing existing mappings. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
BeginUpdate Temporarily suspends adapter refreshes while multiple dataset or grid changes are applied. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
BlobFieldToPicture Decodes the binary content of AField (a BLOB field containing an image) and loads it into ABitmap. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
CheckDataSet Returns True when the adapter has an active, open dataset available for reading. Call before performing dataset operations to avoid exceptions. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
ConvertDataToField Writes the grid cell value for ACell back to AField in the dataset, applying the OnDataToField event. Call after in-place editing to post a single field without posting the entire record. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
ConvertFieldToData Reads the current value of AField from the dataset and converts it into ACellValue, firing OnFieldToData for custom overrides. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
CreateColumns Rebuilds the grid's column list from the current Columns collection (or from all dataset fields when Columns is empty and AutoCreateColumns is True). (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
DataSetCanModify Returns True when the bound dataset allows record modification (CanModify is True and the dataset is active). (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
DataSetCancel Cancels any pending edit or insert operation, equivalent to calling DataSource.DataSet.Cancel. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
DataSetDelete Deletes the current dataset record, equivalent to calling DataSource.DataSet.Delete. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
DataSetDisableControls Suppresses dataset change notifications to all linked controls. Call around bulk data operations to avoid redundant grid refreshes; always pair with DataSetEnableControls. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
DataSetEdit Puts the bound dataset into edit mode for the current record, equivalent to calling DataSource.DataSet.Edit. Raises an exception if the dataset is unidirectional or read-only. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
DataSetEnableControls Re-enables dataset change notifications to all linked controls after a DataSetDisableControls call. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
DataSetInsert Appends a new record to the dataset and puts it into insert mode, equivalent to calling DataSource.DataSet.Insert. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
DataSetIsEditing Returns True when the dataset is currently in edit mode (dsEdit state). (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
DataSetIsInserting Returns True when the dataset is currently in insert mode (dsInsert state). (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
DataSetLocate Locates a record in the dataset by matching AKeyValues against AKeyFieldNames (comma-separated). Returns True when the record is found and the dataset is repositioned to it. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
DataSetPost Posts the current edit or insert operation to the dataset, equivalent to calling DataSource.DataSet.Post. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
DeleteRow Deletes the dataset record represented by grid row ARow. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
EditCell Starts in-place editing for the dataset field represented by ACell. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
EditSetData Stores the value from an in-place editor into the pending dataset field value for ACell. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
EndUpdate Resumes adapter refreshes after BeginUpdate and refreshes the grid when needed. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
GetActiveRow Returns the zero-based grid row index that corresponds to the dataset's current record. Returns -1 when no record is active. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
GetGridColumnIndex Maps an adapter column index to the corresponding grid column index. Returns -1 when no mapping exists. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
InsertRow Inserts a new dataset record before the record represented by grid row ARow. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
IsValidDataCell Returns True when ACell falls within the data area of the grid (i.e. not a fixed row or column and within the current dataset bounds). (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
IsValidDataRow Returns True when ARow is a data row (not a fixed row and within the current dataset record count). (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
LoadAllData Loads all dataset records into an in-memory buffer regardless of the current LoadMode. Useful before performing bulk export or client-side sort/group operations on datasets that do not support random access. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
LoadValuesFromField Fills AValues with the distinct string values of AField by iterating all records. Used to populate filter drop-down lists. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
ReloadFromDataSet Forces the adapter to re-read the current dataset state and repopulate the grid from scratch. Call after programmatically changing dataset data outside the adapter. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
RemoveAllColumns Removes all items from the Columns collection and deletes the corresponding grid columns. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
RemoveAllFields Clears all field name bindings in the Columns collection without removing the columns from the grid. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
ResetActiveRecord Navigates the dataset back to the record that was active before the last SetActiveRecord call. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
SelectCell Selects the grid cell and synchronizes the dataset position with the selected data row. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
SetActiveRecord Navigates the dataset to the record corresponding to grid row ARow. Returns True on success. Does not trigger grid selection events. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
Update Recalculates the grid layout and refreshes visible cells. Call after programmatically changing column or row structure without triggering a full data reload. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)

Events

Name Description
OnAfterApplyFilter Fired after the adapter applies a filter expression to the dataset. Use to update UI state that reflects the active filter. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
OnBeforeApplyFilter Fired before the adapter applies a filter expression. Modify or clear the expression to adjust or suppress filtering. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
OnDataToField Fired when a modified cell value is about to be written to a dataset field. Set Handled to True to take over the field assignment. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
OnFieldToData Fired when a dataset field value is read into a cell. Set Handled to True to override the default conversion. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
OnFilterData Fired after a sort operation is requested by the user. Handle this event to apply custom dataset-level sorting instead of the grid's built-in sort. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
OnGetFilterValues Fired when a column's filter drop-down requests its value list. Populate the supplied TStrings to provide a custom list. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
OnGetHTMLTemplate Fired before the adapter evaluates an HTML cell template, allowing the template string to be replaced per cell. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
OnGetHTMLTemplateData Fired for each unresolved field placeholder in an HTML template. Supply the replacement HTML string for the named field. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
OnGetRecordCount Fired when the adapter cannot determine the dataset record count. Assign ARecordCount to provide the correct value for grid row sizing. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)
OnSortData Fired after a sort request is initiated through the grid UI. Handle this event to apply a custom sort to the dataset rather than relying on the adapter's default sort logic. (inherited from TTMSFNCCustomDataGridDatabaseAdapter)

Used by