Overview
TheTee.GridData.Rtti unit provides several classes to automatically link TeeGrid with records, objects, arrays, and generic collections using Delphi’s RTTI (Runtime Type Information) system.
These classes use reflection to automatically discover and bind to record fields and class properties, eliminating the need for manual column setup.
Classes
TVirtualDataRtti
Base class that provides RTTI-based data binding functionality. Typically not used directly.TVirtualData<T>
Generic class that binds to any type using RTTI. This is the most flexible adapter and can handle:- Single records or objects
TArray<T>- Dynamic arraysTList<T>- Generic listsTObjectList<T>- Object lists
Helper Classes
For convenience, the following type aliases are provided:TVirtualArrayData<T>- Alias forTVirtualData<TArray<T>>TVirtualArray2DData<T>- Alias forTVirtualArrayData<TArray<T>>TVirtualListData<T>- Alias forTVirtualData<TList<T>>TVirtualObjectListData<T>- Alias forTVirtualData<TObjectList<T>>
TVirtualData<T> Constructor
Creates a new TVirtualData instance for the specified data.Signature:Parameters:
AData- Reference to the data to bind (array, list, record, or object)AVisibility- Which member visibility levels to include (default: public and published)AMembers- Whether to include fields, properties, or both (default: both)AAncestor- Whether to include ancestor class members (default: false)
TBaseVirtualData Constructor (Advanced)
Creates a data adapter from an object’s property (available only with NEWRTTI support).Signature:Parameters:
AObject- The object containing the propertyAProperty- Name of the property to bindACount- Fixed count (for array-like properties)AVisibility- Which member visibility levels to includeAMembers- Whether to include fields, properties, or bothAAncestor- Whether to include ancestor class members
Types
TVisibility
Set of member visibility levels:TRttiMembers
Specifies which RTTI members to include:Both- Include both fields and propertiesFields- Include only fieldsProperties- Include only properties
Methods
AddColumns
Automatically adds columns based on the type’s RTTI information.Signature:Parameters:
AColumns- The columns collection to populate
AsFloat
Retrieves a cell value as a floating-point number.Signature:Parameters:
AColumn- The column to read fromARow- The row index
AsString
Retrieves a cell value as a string.Signature:Parameters:
AColumn- The column to read fromARow- The row index
Count
Returns the number of rows (array/list items).Signature:Returns:
The number of items in the array or list.
DataType
Returns the RTTI type information for a column.Signature:Parameters:
AColumn- The column to query
SetValue
Sets a cell value, updating the underlying array or list item.Signature:Parameters:
AColumn- The column to updateARow- The row indexAText- The new value as a string
Usage Examples
Binding to Arrays
Binding to TList
Binding to Object Lists
Binding to Single Records
Controlling Visibility
Fields vs Properties
2D Arrays
Including Ancestor Members
Type Support
The RTTI data adapters automatically handle these types:- Numeric types: Integer, Int64, Single, Double, Currency
- String types: string, AnsiString, WideString
- Boolean types: Boolean, ByteBool, WordBool, LongBool
- Date/Time types: TDate, TTime, TDateTime
- Enumerated types: Displayed as their string names
- Set types: Displayed as comma-separated values
Performance Considerations
However, for most applications with datasets under 50,000 rows, the performance is excellent and the convenience is worth it.See Also
- TVirtualData - Base virtual data class
- TVirtualDBData - Database adapter
- Arrays and Lists Guide - Complete guide to binding arrays and lists
- Custom Virtual Data - Creating custom adapters
