LMD GridPack Guide


Grid Data


TLMDGrid works with Variant based data. This means that the value of a cell is always of Variant type. The grid control provides a variety of methods and properties to access cell values:

 

Cells[ACol: Integer; ARow: Integer]

Indexed property can be used to read or write data values.

DataRowCount

Property can be used to get or set row count.

CurrentRow

Property allows to get or set current row index.

Columns

Property provides access to column collection, which allows to determine column count, add/remove or reorder columns or just iterate them.

 

Data Source

 

By default, grid data is stored in the internal data source. The internal data source is created as a part of every grid object. It supports all grid features, like dynamic (on-the-fly) columns creation or removing, columns reordering, data sorting, ect. There are no direct access to the internal data source, the user should manipulate grid data using properties, specified above. The internal data source is a simple solution; however, it stored all data as real Variant values, which is not absolutely optimal from the memory or performance viewpoint.

 

So, if an application needs to store data outside of default internal data source, it can store the data externally, implementing a bridge between external data and the grid control; This can be accomplished descending your own data source from TLMDGridCustomSource class. Then, the data source should be associated with the grid using grid's CustomSource property. It should be noted that custom data source implementation is a task for beginners.

 

Data Aware Grid

 

LMD-Grid package also provides a native connection with Delphi's database system. TLMDDBGrid is a data aware control, which can be used in this case. TLMDDBGrid provides a DataSource property, which is of standard TDataSource type. In this case required columns will be created automatically at run-time; however, its possible to configure columns manually, using design-time column editor. In the later case every column should be connected to the data source field using column's FieldName property.

 

For TLMDDBGrid advanced grid functionality depends of underlaying TDataSet; so, for example, just setting grid's RowCount will, of course, fail, because TDataSet does not allow to change row count in this way. Also, sorting is supported in TLMDDBGrid only via OnDataSetSort event, which means that the user should handle sorting of underlaying data set manually.

 

TLMDDBGrid introduces a special lookup chooser, which can be used additionally to standard choosers. Its will be used by default for lookup data set fields. It should not be used with non-lookup fields.