Data Grid Question

Jan Schenkel janschenkel at yahoo.com
Sat Nov 21 05:09:27 EST 2009


--- On Fri, 11/20/09, RevList <RevList at CreaTECHSol.com> wrote:
> I have to admit that I do not use the
> Data Grid often enough to be
> comfortable with it, and I have problems finding how to do
> things.
> 
> I have a simple 3 column table style datagrid and I
> populate the first two
> columns though a SQLite database.  No problem.  I
> would like to run a
> calculation on the second cell in each row and populate the
> third cell
> with this calculated result.
> I have a function called TimeOnLine that returns the
> calculated result.
> 
> I have added a third column to my datagrid an am looking at
> the FilInData
> scipt for the column behaviour.  I do not know the
> syntax to retrieve the
> value of the second cell so that I can call my function.
> Can anyone help?
> 
> on FillInData pData
>    -- This message is sent when the Data
> Grid needs to populate
>    -- this template with the column data.
> pData is the value to be
> displayed.
>    
>    -- Example:
>    set the text of field 1 of me to
> TimeOnLine(?????)
> end FillInData
> 
> 
> Stewart
> 

Hi Stewart,

The parameter sent to FillInData, pData, is an array with one element for each column name. So assuming your second column is named "Foobar", then your FillInData handler would look something like:
##
on FillInData pData
  set the text of field 1 of me to TimeOnLine(pData["Foobar"])
end FillInData
##

It's one of the most powerful aspects of datagrids, that we can do this ourselves via straightforward scripting, without having to deal with the complexity of the underlying mechanism.

HTH,

Jan Schenkel
=====
Quartam Reports & PDF Library for Revolution
<http://www.quartam.com>

=====
"As we grow older, we grow both wiser and more foolish at the same time."  (La Rochefoucauld)


      



More information about the use-livecode mailing list