Well, I can sort the records of the datagrid all right.
But how can I loop through the data
in the order the records are displayed in the datagrid in order to compute a running total? The balance of record 1 (first record displayed, the record with oldest date) must be equal to the first money input/output amount, then the balance of each subsequent record must be equal to the input/ouput of that record plus the balance of previous record. Something like:
1/01/2011 +33 =33
2/02/2011 +10 = 43
3/03/2011 - 4 =39
etc.
To make sure if I can process the datagrid records in date order, I tried the following which does not work:
Code: Select all
on sortGrid
dispatch "SortDataByKey" to group "laliste" with "MEDateFld" , "dateTime" , "ascending"
put the dgData of group "laliste" into myData
put the keys of myData into kList -- kList is not sorted
sort lines of kList -- now kList is sorted
answer kList -- nothing fancy: 1, 2, 3 etc.
repeat for each line k in kList
put k && myData[k]["MEDateFld"] & return after s
end repeat
answer s -- the dates are not sorted here; same if I remove the line "sort lines of kList"
end sortGrid
I need to loop through the data in date order.