Why I Needed a Data Grid
A data grid is simply a way to present data in a table-style format, similar to a table in Word or an Excel spreadsheet. (You can also display data in a label-style format.) Let me explain why I needed it. In my Q sort tool I provide a report to users that lists how related their Q sort results are to each and every other person who did the sort. This relationship is expressed by a correlation coefficient ranging from +1 to -1 where +1 is a perfect, positive correlation and -1 is a perfect negative correlation. Perfect correlations never happen in the social sciences - at least I've never seen one. Instead one gets a number somewhere in-between. A strong positive number indicates that the two people's sorts share a statistical relationship in the same direction. That is, their Q sorts indicate a shared point of view. They are of like minds. A strong negative number also indicates a statistical relationship, but in the opposite direction. To use the example of ice cream flavors, two people who seem to like or dislike the same flavors would have a strong positive correlation number, whereas two people who have very different tastes would have a strong negative number: "I love chocolate, but I hate pistachio." "Really? I hate chocolate but love pistachio."
Up to now, I've been displaying these data to the user within a simple, hard to read - and ugly - text field:
Ugliness aside, I've also found that some people misinterpret the data mainly because they don't necessarily see the all important comma in the right column in-between the person's name and the correlation. The zig zagging right edge of the data also makes it tough to read. I also have many non-US people who grew up using the comma instead of the period as the decimal point. This causes further confusion.
In contrast, a data grid allows the same data to be displayed in a clearer, neatly arranged, table-style format:
So, How Does a Data Grid Work?
Examples of a Few Key Scripts
1: on mouseUp 2: ## Create tab delimited data. 3: ## Note that first line has name of columns. 4: ## Providing names tells Data Grid how to map 5: ## data to appropriate columns. 6: put "Live" & tab & "Code" & cr & \ 7: "ALABAMA" & tab & "AL" & cr & \ 8: "ALASKA" & tab & "AK" into theText 9: ## Let Data Grid know that first line has column names 10: put true into firstLineContainsColumnNames 11: set the dgText [ firstLineContainsColumnNames ] of group "DataGrid 1" to theText 12: end mouseUp
But, There's So Much More
1: global varComparisonSummaryDG, varAllComparisonsDG, varOneGroupOnlyDG 2: on mouseDown pMouseBtnNo 3: set the itemDelimiter to tab 4: dgMouseDown pMouseBtnNo 5: //Gets the number of the row clicked on 6: put the dgHilitedLines of me into L 7: //Gets the value of a column in a particular row 8: put GetDataOfLine(L, "Name") into varName 9: put varName into line 2 of field "comparison label" 10: //show field "one group only" 11: // put empty into field "one group onlyDG" 12: put empty into varOneGroupOnlyDG 13: set the dgData of group "One Group OnlyDG" to empty 14: put the number of lines of varAllComparisonsDG into M 15: repeat with i=1 to M 16: if line i of varAllComparisonsDG = varName then 17: repeat with j=i to M //after name is found, look for the next empty line 18: if item 1 of line j of varAllComparisonsDG is "SUM" then exit repeat 19: end repeat 20: put line i+1 to j-1 of varAllComparisonsDG into varOneGroupOnlyDG 21: set the dgText [ false ] of group "One Group OnlyDG" to varOneGroupOnlyDG 22: exit repeat 23: end if 24: end repeat 25: set the itemDelimiter to comma 26: end mouseDown
- Line 6 puts the number of the line just clicked into the variable L.
- Line 8 puts the data in the column "Name" into the variable varName.
- Line 9 just puts the person's name in a label field near the top of the screen to make it clearer who is the person being compared.
- The global variable varAllComparisonsDG contains all of the comparison data. Lines 15-24 systematically looks through all of this data to find the person's name. Once found, it notes where in the variable the data for this person is found in line numbers. (A variable holds data in a way that is similar to a field.)
- Line 20 puts this data into a variable named varOneGroupOnlyDG.
- Line 21 puts the data in variable varOneGroupOnlyDG into the second data grid shown on the screen on the right.