I have been unable to figure out how to get data from an array into a data grid. The array consists of 18 "records". There are 18 keys, each being a student's name. For each student (key) there are 5 elements (scores). I can look at the variable list for the array and it can be expanded to show the student names (keys) and each of those can be expanded to show the 5 scores (elements) for each, so I know the array works. Each element is named and the names appear perfectly, along with their values (scores) in the variable listing.
I have a created data grid that consists of 18 rows and 7 columns. The columns are all named. The first column is "Name" and I would like to populate each row in that column with the key (student's name). The next 5 columns are scores for different subjects (these are the named elements following each key). The last column is labeled "Total" and I would like to add up all 5 scores for the student and put the sum there.
I have been completely unable to figure out how to get the array data into the data grid. It seems like it shouldn't be so hard to do.
Any help would be most appreciated.
Colorado
Populating a Data Grid with Array Data
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: Populating a Data Grid with Array Data
Hi. If you have a datagrid (group "yourDG")
Make an array, set a datagrid property ("the dgText") on your datagrid :
But do go here:
http://lessons.runrev.com/spaces/lesson ... With-Data-
Craig Newman
Make an array, set a datagrid property ("the dgText") on your datagrid :
Code: Select all
on mouseUp
repeat with y = 1 to 4
put random(99) into myArray[y]
end repeat
combine myArray with return and tab
set the dgText of group "yourDG" to myarray
end mouseUp
http://lessons.runrev.com/spaces/lesson ... With-Data-
Craig Newman
Re: Populating a Data Grid with Array Data
Craig,
Thanks so much for your response to my query. My problem seemed to be that I used a name for a key and not a (line) number. I converted my array to use numbers as keys and then used "set dgData..." and got it working. Now I am trying to format the cells to be just 2 decimal places and I am just starting to get into the fillInData function.
Is there any way to fill in a data grid using something other than a number as a key? I tried everything but never got it to work. The code I added to put the numbers as keys is a bit of a kludge so I would like a purer solution if one is possible.
Colorado
Thanks so much for your response to my query. My problem seemed to be that I used a name for a key and not a (line) number. I converted my array to use numbers as keys and then used "set dgData..." and got it working. Now I am trying to format the cells to be just 2 decimal places and I am just starting to get into the fillInData function.
Is there any way to fill in a data grid using something other than a number as a key? I tried everything but never got it to work. The code I added to put the numbers as keys is a bit of a kludge so I would like a purer solution if one is possible.
Colorado