Data Grids ???

Trevor DeVore lists at mangomultimedia.com
Mon Apr 13 16:32:36 EDT 2009


On Apr 13, 2009, at 3:49 PM, Richmond Mathewson wrote:

> Added a 9th column as per your suggestion; the additional data was not
> displayed - I had to reimport the tab-delimited text file.

Ah that is right. The dgText importer only iterates over the number of  
columns in the first row.

> This means that when a data set where the first row is not filled  
> across
> is imported some of the data is lost . . . doesn't make me feel very
> comfy.

Data grids work with arrays under the hood rather than tab delimited  
text. Using the property inspector to assign tab delimited text is  
merely a convenience and it creates some columns for you automatically  
if needed so that you see something. If you are coding an application  
you will be setting data grid properties yourself in which case you  
can specify how many columns should be imported.

> Why I am I so picky?
>
> 1. Maybe I am authoring a standalone (or stack with runner) for  
> unknown
>   end-users who may be importing their own data: I won't know how many
>   columns their data will consist if.

You have two options in this case.

1) When setting the dgText property you can specify that the first  
line of the data contains a header. The header dictates which column  
each item in your tab delimited lines will be put into.

2) Convert the data into an array that you can assign to the dgData  
property (which is what the data grid uses under the hood anyway).

> 2. Why is the number of columns set by row number 1? surely it could,
>   just as logically, be set by the row with the largest number of
>   columns?


That is just how it dgText is written right now if you don't pass in  
true for the pFirstLineContainsHeaders parameter (which the Property  
Inspector doesn't). As I mention above, as the developer you will be  
using setting the data grid properties when you import data and you  
should be providing the names of the columns that the data should be  
mapped to.

Perhaps this lesson will help explain things as well:

How Do I Populate a Data Grid with Data?
<http://revolution.screenstepslive.com/spaces/revolution_tools/manuals/datagrid/lessons/3389-How-Do-I-Populate-a-Data-Grid-With-Data- 
 >

Also, I recommend taking a look at the manual:
<http://revolution.screenstepslive.com/spaces/revolution_tools/manuals/datagrid 
 >

Regards,

-- 
Trevor DeVore
Blue Mango Learning Systems
ScreenSteps: http://www.screensteps.com
Developer Resources: http://revolution.bluemangolearning.com



More information about the use-livecode mailing list