Datagrid - GetDataForLine

Michael Doub mike at doub.com
Fri Dec 2 18:22:19 EST 2011


Marty, I am no expert but let me share what I have learned over the past few weeks.
Don't be too concerned about the database examples.   Look at the message handler carefully.

command GetDataForLine pLine, @pDataA

On every call to this handler the DataGrid is asking you to provide the data for just one row  and the identifer of this row is pLine.   So you just need to be able to return only the data associated with that one row.   How you do this is up to you.  Each row could be as simple as a line in a field.  You just have to put the data from line into an array and return it in pDataA.   

As the datagrid is scrolled around, it will call GetDataForLine when it anticipates the need for data.  It looks like the dataGrid requests a few extra rows that are not visiable to make sure that scrolling looks smooth.  So if 10 rows are visiable the datagrid is asking for 12 or so worth of data.

You will start getting GetDataFOrLine message as soon as you set dgNumberOfRecords.  All of the rows when using this technique are fixed height rows.  The datagrid must assume this to figure out the size of the scroll area.   I have a situation where I saved to dgVScroll in a custom property of the card in the close card hander as well as clearing the datagrid.  I  reload the datagrid in the open card handler an re-set the dgvScroll and the datagrid is in the same location as before leaving the card.
    
To answer your questions directly:

The dgNumberOfRecords should be set to the total number of records in my data set, correct?  Correct
In my scenario, how do I use the "GetDataForLine" command?   I hope I was clear enough above
Am I wasting time by converting my tab-delimited file to an array?   Yes, I don't see the need.   You build pDataA within the GetDataForLine handler.


Regards,
   Mike

    





More information about the use-livecode mailing list