Overview
TVirtualData is an abstract base class that defines the interface for providing data to TeeGrid. It acts as a bridge between the grid and various data sources including databases, arrays, lists, and custom data structures.Concrete Implementations
TeeGrid includes several ready-to-use TVirtualData implementations:TVirtualDBData
Unit:
Tee.GridData.DBConnect to TDataSet and TDataSource for database data.TVirtualArrayData<T>
Unit:
Tee.GridData.RttiUse TArray<T> or TList<T> with RTTI for generic data.TVirtualStringData
Unit:
Tee.GridData.StringsString grid with Cells[Col, Row] interface like TStringGrid.TBIGridData
Unit:
BI.GridDataConnect to TeeBI TDataItem data structures.Abstract Methods
These methods must be implemented in descendant classes.
Required Data Methods
Returns the total number of rows in the data source.Signature:Returns: Total row count
Returns the string representation of data at the specified column and row.Signature:Parameters:
AColumn- The column to readARow- The row index (0-based)
Updates the value at the specified column and row.Signature:Parameters:
AColumn- The column to updateARow- The row index (0-based)AText- New value as string
Column Management
Automatically creates and adds columns to the grid based on the data structure.Signature:Parameters:
AColumns- The columns collection to populate
Loads or refreshes column metadata from the data source.Signature:Parameters:
AColumns- The columns collection to load
Calculates the optimal width for a column based on its content.Signature:Parameters:
APainter- Painter for measuring textAColumn- Column to measure
State Methods
Checks if the data source is empty.Signature:Returns: True if no data is available
Indicates whether the total row count is known in advance.Signature:Returns: True if Count returns an accurate value, False if the count is unknown or approximate
Virtual Methods
These methods have default implementations but can be overridden for custom behavior.
Data Access
Returns the numeric value of data at the specified column and row.Signature:Returns: Numeric value (default implementation converts AsString to float)
Returns type information for the specified column.Signature:Returns: Pointer to RTTI type information, or nil if unknown
Editing
Notifies the data source about edit mode changes.Signature:Parameters:
AMode- Edit mode:Start,Cancel, orFinish
Determines if a column is read-only.Signature:Returns: True if the column cannot be edited
Toggles a boolean value at the specified location.Signature:
Master-Detail
Checks if a row has expandable detail data.Signature:Returns: True if the row can be expanded to show detail grid
Creates and returns a TVirtualData instance for detail data.Signature:Parameters:
ARow- Master row indexAColumns- Columns for the detail gridAParent- Returns the parent column for the relationship
Expansion
Determines if a row can be expanded.Signature:Returns: True if row expansion is supported
Sorting
Checks if sorting by a column is supported.Signature:Returns: True if the column can be sorted
Sorts data by the specified column.Signature:
Checks if data is currently sorted by a column.Signature:Parameters:
Ascending- Returns True if sorted ascending, False if descending
Calculations
Performs calculations on column data.Signature:Parameters:
AColumn- Column to calculateACalculation- Type:Count,Sum,Min,Max, orAverage
Sizing
Calculates optimal height for a cell with multi-line content.Signature:Returns: True if auto-height was calculated
Measures the longest string in a column for auto-width calculation.Signature:Returns: Width of longest string in pixels
State Management
Checks if a row index is beyond the end of data.Signature:Returns: True if row index exceeds available data
Events and Callbacks
Protected Event Triggers
Triggers the OnRefresh event to notify the grid of data changes.Signature:
Triggers the OnRepaint event to request a visual update.Signature:
Notifies that a specific row’s data has changed.Signature:
Notifies about editing state changes.Signature:
Event Properties
Fired when data needs to be refreshed from the source.
Fired when the grid needs to be repainted.
Fired when the current row changes.Signature:
Fired when editing starts or stops.Signature:
Class Methods
Factory method to create appropriate TVirtualData instance from a component.Signature:Returns: TVirtualData instance or nil if source is not supported
Checks if a column contains numeric data.Signature:Returns: True for numeric data types
Example: Custom TVirtualData Implementation
Registration
Register custom TVirtualData classes to enable automatic detection:See Also
TTeeGrid
Main grid component
TCustomTeeGrid
Abstract base grid class
