Displaying Large Amounts of Data
Setting the dgText property or creating an array and setting the dgData property of a data grid is the easiest way to display your data. But what about situations where creating an array is too time intensive and you already have the data in another format? A data grid can handle these situations for you as well using a feature called callbacks.
Download the attached sample stack and database that shows how to use the techniques described in this lesson to display data from a SQLite database.
You can download the stack for this lesson here: https://tinyurl.com/ybrrfoa5
The dgNumberOfRecords Property
Normally a data grid reports the number of records based on the number of numeric indexes in the first dimension of the dgData array. If you set the dgNumberOfRecords property, however, the data grid stops using an internal array and issues a callback message whenever it needs to display data in a line.
Important: When using this technique properties like dgData, dgText, dgDataOfIndex, etc. will no longer return values. The data grid is just displaying records from your data source. It does not store any of that data internally.
This diagram demonstrates how this works. If you were to set the dgNumberOfRecords to 10000 then the data grid would start sending the GetDataForLine message whenever it needed to display a row. Your responsibility is to fill in the data that the data grid needs by handling the GetDataForLine message. To do that you define GetDataForLine as follows:
command GetDataForLine pLine, @pDataA end GetDataForLine
You can define this handler in the data grid script or anywhere else in the message path. Just fill in pDataA with the appropriate data and the data grid will display it.