Newbie Data Grid question
Trevor DeVore
lists at mangomultimedia.com
Mon Dec 14 08:58:13 EST 2009
On Dec 13, 2009, at 4:10 PM, James Hurley wrote:
> Yes the columns already exist.
>
> If I set pFirstLineContainsHeaders to false, the field is populated
> with data but the columns are set to Col 1, Col 2 etc.
>
> If I then set set pFirstLineContainsHeaders to true (with the
> columns already set to Col 1, Col 2, etc.) the columns remain
> unchanged but the body of the text is empty.
The most likely cause is that you don't have a column labeled with
"Col 1" or "Col 2" in the first line of the data. Therefore the data
you are setting is not mapping to an existing column in the Data Grid.
Data Grid's do not behave like fields in that you can just swap text
in and out randomly. You should be defining the columns (using the
Property Inspector or by setting the dgData["columns"] property) and
then assigning data to the Data Grid that explicitly states which
column data goes into.
The reason for this is that Data Grid columns are objects in and of
themselves. They have properties that are set independently. If you
want to wipe them all out at once then you first create the columns,
set the column properties and then assign the data.
As a side note the fact that dgText automatically creates columns for
you is unfortunate in my opinion. This behavior was requested so that
someone could just set the text of the Data Grid and see instant
results. While that may be beneficial for "instant gratification" I
think it just causes more confusion then anything in the end.
The Data Grid isn't meant to be a quick and dirty means of displaying
data but rather a means of displaying data with lots of control over
the visual elements used to display that data.
--
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