DataGrids: dgDataOfIndex calls "FillinData" twice?

Trevor DeVore lists at mangomultimedia.com
Wed Sep 23 10:25:59 EDT 2009


On Sep 23, 2009, at 8:29 AM, David Bovill wrote:

> I guess this is a question for you Trevor :)
>
> In trying to debug an interface that makes asynchronous calls to  
> update a
> datagrid I tacked donw the following feature / aspect of using:
>
> set the dgDataOfIndex [indexNum] of grp "Datagrid" to recordArray
>
> And that is that it calls you user defined "FillinData" twice, while:
>
> set the dgData of grp "Datagrid" to dgArray
>
> call "FillinData"  only once.

When you update the data for a row in a Data Grid with rows of varying  
height the data grid needs to recalculate the height of the row based  
on the new data. This needs to happen regardless of whether or not the  
control is visible on the screen as the total height of the Data Grid  
content needs to be updated.

If the row you are updating is already being displayed in the Data  
Grid then the visible control is redrawn. If the row isn't being  
displayed in a control then a copy of your row template is created  
just for this purpose (and then immediately destroyed). This is what  
is going on in _UpdateIndexWithNewData.

The additional FillInData handler is probably being called from  
_RedrawList beause _RefreshIndexes marks the row as dirty (this  
happens in _ResetControlsOfIndex). In your particular circumstance I'm  
not sure the row needs to be marked as dirty since it was updated in  
_UpdateIndexWithNewData. I would have to look into this more closely  
before I made any changes however.

> Tracking this down using the executioncontexts it seems that "set the
> dgDataOfIndex" first calls the handlers that "set the dgData" does  
> and then
> in addition an extra:

I believe the calling chain in your cause would be as follows:

set the dgDataOfIndex
     :_RefreshIndexes
         :_UpdateIndexWithNewData (calls FillInData)
         :_ResetControlsOfIndex
         :_RedrawList (calls FillInData since the row was marked as  
dirty)

> In my case where I have a lot of action updating individual lines of  
> the
> datagrid each second, I want to do this as fast as possible and also  
> to
> avoid possible recursion with the async loads. It would help greatly  
> to
> understand why "FillInData" needs to be called twice with "set the
> dgDataOfIndex" and therefore what my handler should do with each call.

I will look into seeing if the 2nd call to FillInData can be removed  
though it will have to wait until after the Pro App Dev course next  
week.

-- 
Trevor DeVore
Blue Mango Learning Systems
ScreenSteps: http://www.screensteps.com
Application Development with Revolution Course: http://revolution.bluemangolearning.com/software/revproappdev/



More information about the use-livecode mailing list