(data grid) is there a good workaround for obtaining other column values in FillInData for a Data Grid Table?
zryip.theslug at gmail.com
Thu Aug 19 04:47:05 CDT 2010
On Thu, Aug 19, 2010 at 1:48 AM, Josh Mellicker <josh at dvcreators.net> wrote:
>>> If you set a custom behavior for the column you want the sum in, and
>>> where it has the section for filling data, put
>>> put the dgDataOfIndex[ the dgIndex of me] of the dgControl of me
>>> into theDataA
>>> set the text of field 1 of me to (theDataA["Col 2"] + theDataA["Col 3"])
>>> Should work fine. Not positive this is the best method, but seems to
>>> work dandy fine with small datasets. Haven't tried it with big ugly
>> If you didn't want to fetch all of the data for the entire row you could use GetDataOfIndex. GetDataOfIndex only retrieves the value of a specific column.
>> put the dgIndex of me into theIndex
>> set the text of field 1 of me to (GetDataOfIndex(theIndex, "Col 2") + GetDataOfIndex(theIndex, "Col 3"))
> And this code goes into FillInData in the table's behavior, right?
You have two options:
- change the script in the column behavior for the column you want to
display a sum.
- or define a default column behavior for the datagrid
If you choose the first option, change your script with a code like this:
on FillInData pData
put the dgIndex of me into tTheIndex
put sumOfColumn(tTheIndex,"Col2","Col3") into pData
set the text of the long id of me to pData
function sumOfColumn pTheIndex
put 0 into tTheSum
repeat with x = 2 to the paramcount
add GetDataOfIndex(pTheIndex,param(x)) to tTheSum
If you prefer the second solution, you're welcome to download and use
the code of the sample stack I proposed in my first reply ;)
-Zryip TheSlug- wish you the best! 8)
More information about the use-livecode