Newbie Data Grid question

James Hurley jhurley0305 at sbcglobal.net
Mon Dec 14 13:11:17 EST 2009


>
> Message: 27
> Date: Mon, 14 Dec 2009 08:58:13 -0500
> From: Trevor DeVore <lists at mangomultimedia.com>
> Subject: Re: Newbie Data Grid question
> To: How to use Revolution <use-revolution at lists.runrev.com>
> Message-ID: <4392D851-15E4-48F7-83FB-D04224A7028B at mangomultimedia.com>
> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes
>
> 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

Trevor (and Andre.Bisseret),

Thanks you for the very thoughtful reply(s).

It is heartening to see something defended by its parent. My sincere  
apologies for treating your offspring in such a quick and dirty  
fashion :-)
I'm sure I will appreciate the richness  of this new Run Rev object in  
time--see below.

FIrst to satisfy my quick and dirty needs, I find that the following  
works well to get data displayed in a data grid field:

on mouseUp
    put field "data" into tData --Tab delimited text
    --The first line of tData contains the column names
    put line 1 of tData into tHeaders
    replace tab with cr in tHeaders
    set dgProp["Columns"] of group "DataGrid"  to tHeaders --Thanks to  
Andre for this line.
    set the dgText [ true ] of group "DataGrid" to tData
end mouseUp

Now to reinforce your point about the richness of this more complex  
object:
In another context, I would like to be able to click on the first  
column header and have it sort the grid by the LAST word of each in  
the first column.
Is it possible to access (and modify)  the script that the column  
headers runs?

Thanks again for nursing us through the infancy of data grids.

Jim Hurley











More information about the use-livecode mailing list