Page 1 of 1

Using Datagrids

Posted: Thu Mar 17, 2011 8:51 pm
by stevewhyte
Hi,

I'm after some clarification with regards to datagrids. After looking over some LiveCode documentation, I have managed to successfully implement a datagrid. However, I'm unsure over a few things in the code and I need to produce pseudocode for it.

The bit that confuses me is the copying of the array data into this temporary storage area called theDataCardInfo and then the copying of the data into the datagrid using group.

Is it possible to copy the data from the arrays directly into the data grid named "DataGrid 1" without using this temporary storage area?

Is this storage area an array? If so, could someone clarify how this works and perhaps translate the loop below into pseudocode?

Thanks in advance!

Steven :D


------ CODE ------

// Set up local variables
local theVideoCardInfo
local CardCount

// Clear text from the fields
put empty into field "TotalCardsFound"
put empty into field "Sub Heading"

// Display the heading
put "Displaying All Graphics Cards" into field "Sub Heading"

// Zero number of video cards found
put 0 into CardCount

// Display all video cards
repeat with loop = 1 to MaxVidCards

// Increment number of video cards displayed. This is also used to determine which line
// video card details appear within data grid.
add 1 to CardCount

// Copy video card data from array to a temporary storage area??
put arrayProductName[Loop] into theVideoCardInfo[CardCount]["name"]
put arrayProductRam[Loop] into theVideoCardInfo[CardCount]["memory"]
put arrayProductClockSpeed[Loop] into theVideoCardInfo[CardCount]["speed"]
put arrayProductCost[Loop] into theVideoCardInfo[CardCount]["cost"]
end repeat

// Copy video card data from array to data grid??
set the dgData of group "DataGrid 1" to theVideoCardInfo

Re: Using Datagrids

Posted: Mon Mar 21, 2011 1:33 pm
by trevordevore
It doesn't look like you can bypass the step. The data is spared across multiple arrays (arrayProductName, arrayProductRam, etc.). In order to set the dgData property of the data grid you need a single array. The repeat loop combines the data into a single array.

--
Trevor DeVore
Blue Mango Learning Systems
ScreenSteps: http://www.screensteps.com
LiveCode Resources for Developers: http://livecode.bluemangolearning.com