Page 1 of 1

Populating a specific index of a datagrid

Posted: Thu Jul 10, 2014 4:25 am
by quailcreek
What I'm trying to do is search column "ID" in MyDataGrid for a match of the string in fld "ID"
When the strings match put a 1 at the index between the row that contains the string in fld "ID" and the column matching fld "Method"
What I have below works but it puts the "1" into the row 3 below the row where the string was found. In the if statement I have an answer theLineNo which validates the correct row number. So what am I doing wrong?

Tom
on mouseUp
put fld "Method" into theMethod
put fld "ID" into theID
put the dgNumberOfLines of grp "MyDataGrid" into theCount

repeat with theLineNo = 1 to theCount
put the dgDataOfLine[theLineNo] of grp "MyDataGrid" into theDataA
put theDataA["ID"] into foundID

if theID = foundID then
answer theLineNo
dispatch SetDataOfIndex to grp "MyDataGrid" with theLineNo,theMethod,"1"
end if
end repeat

send RefreshList to grp "MyDataGrid"
put the uSumOfColumn [theMethod] of group "MyDataGrid" into fld "Total"
end mouseUp

Re: Populating a specific index of a datagrid

Posted: Thu Jul 10, 2014 10:28 am
by Klaus
Hi Tom,

BEWARE: INDEX <> LINE!

You need to stick to one of them TRHOUGHOUT :D
...
answer theLineNo
## dispatch SetDataOfIndex to grp "MyDataGrid" with theLineNo,theMethod,"1"
dispatch SetDataOfLine to grp "MyDataGrid" with theLineNo,theMethod,"1"
...
That should fix it.


Best

Klaus

Re: Populating a specific index of a datagrid

Posted: Thu Jul 10, 2014 4:44 pm
by quailcreek
Thanks Klaus. Line instead of Index does make sense.

Tom