LiveCode LessonsLiveCode Data Grid Working With Data Grid FormsHow Can I Speed Up Drawing When "fixed row height" is False?

How Can I Speed Up Drawing When "fixed row height" is False?

When you set the dgProp["fixed row height"] property of a Data Grid to false the Data Grid must draw all records in order to determine the total height. That means that FillInData and LayoutControl are called for every record in the Data Grid. This can be time intensive depending on the amount of data.

This lesson will show you a technique that can speed up the calculation of the total height of the data in situations where the rows can only have heights of known values.


When the Data Grid loops through the data to calculate the height the message CalculateFormattedHeight will be sent to the Row Template. If your Row Behavior handles this message then the Data Grid will use the integer value that you return rather than calling FillInData and LayoutControl.

Here is an example that uses CalculateFormattedHeight to return the height of a row based on whether or not the row is expanded. Just place the CalculateFormattedHeight message in your Row Behavior script.

on CalculateFormattedHeight pDataArray

if pDataArray["expanded"] then

return 74


return 20

end if

end CalculateFormattedHeight

on FillInData pDataArray


end FillInData


Add your comment

E-Mail me when someone replies to this comment