Page 1 of 1

Very Simple DG Table Question...

Posted: Tue Feb 11, 2014 12:34 am
by Gage
I feel really dumb asking this, because I swear it has to be something VERY obvious I am missing, but here goes.

I am testing a very simple empty DG Table. I use a button on the same card to populate it, using the following script.

----
on mouseUp
repeat with x=1 to 100
put "This is line " & x & " of card " & the short name of this card into tDataA[x]["Label1"]
end repeat

lock screen
set the dgData of group "DataGrid 1" of this card to tDataA
unlock screen
end mouseUp
----

After this, the DG is populated with 100 rows, but all are empty. When I look in the DG's Property Inspector > Contents pane, there are 100 empty-looking lines (might be a "tab" char in there for each line).

I have looked at the variable watcher after the array is created, and it is not empty... so, where do all of the contents go between filling the array and setting the dgData of the DG to that array?

NOTE: For some reason, when I switched the DG to Form from Table style, it worked fine, and the Contents and DG itself both reflected a single column of information, exactly as I created it in the array.

So, I am stumped. Let me know if I am doing something obvious wrong.

Thanks in advance!
Phil E.

Re: Very Simple DG Table Question...

Posted: Tue Feb 11, 2014 12:43 am
by Gage
Well, I assumed that the DG would automatically create columns for each key of the array that is used to fill the contents, but it looks like it does not, contrary to what I thought I read in the tutorials on www.livecode.com ... very strange.

The resolution was to add a column in the Columns pane of the Property Inspector with the same name as the key name in the array I created and passed in.

Hope this is helpful to anyone else who is confused by something similar.

Cheers,
Phil E.