Datagrid: How get column data from other column behavior

Trevor DeVore lists at mangomultimedia.com
Fri Apr 9 11:58:31 EDT 2010


On Apr 9, 2010, at 10:46 AM, Andre.Bisseret wrote:

> Assuming I have a datagrid "cellar" with
>
> Appellation / Price
> Bourgogne / 43
> Bordeaux / 38
> Aubance / 25
>
> I want to change the price of one wine
>
> 1 - the user has to select a line then
>
> put the dgHilitedLines of grp "Cellar" into tLine
> put the dgDataOfLine[tLine] of grp "Cellar" into theDataA
> ask "What's the price?" with theDataA["Price"]
> put it into theDataA["Price"]
> set the dgDataOfLine[tLine] of group "Cellar" to theDataA

You could also just use SetDataOfIndex here instead of extracting the  
row array, setting a key and reassigning it.

> 2 - Now I would like to be able to change a price but starting from  
> a given wine' name, not from the selection of a its line (not really  
> needed currently, but for learning more about datagrid ;-))
>
> I found the following; for example I have to change the price of the  
> Aubance:
>
> put the dgData of grp "cellar" into theDataA
> repeat for each key theIndex in theDataA
> if theDataA[theIndex]["Appellation"] is "Aubance" then
> Ask "What's the new price for Aubance?"
> put it into theDataA[theIndex]["Price"]
> end if
> set the dgData of grp "cellar" to theDataA
> end repeat

For simple finds you can use FindIndex.

dispatch "FindIndex" to group "cellar" with "Appellation", "Aubance"
put the result into theIndex

if theIndex > 0 then
     -- change pricee of row.
end if

API page: http://lessons.runrev.com/spaces/lessons/manuals/datagrid/lessons/7344-Data-Grid-API

-- 
Trevor DeVore
Blue Mango Learning Systems
ScreenSteps: http://www.screensteps.com
Releasable Revolution Resources for Developers: http://revolution.bluemangolearning.com



More information about the use-livecode mailing list