Newbie Data Grid question

Andre.Bisseret Andre.Bisseret at inria.fr
Tue Dec 15 06:18:17 EST 2009


Bonjour Jim, Trevor and others on this thread ;-)

Le 14 déc. 09 à 19:11, James Hurley a écrit :
...
>
> 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
>
Your handler above, confirmed by Trevoir, helped me a lot to  
understand the possible uses of pFirstLineContainsHeaders.
In order to learn more about data grid, I tried several variations, I  
put below in case it could interest someone :

  local tData,tHeaders,
-- field "data" = lines of tab delimited text -- a Data Grid  
"DataGrid" with 3 columns
  ------------

-- 1 ) IF THE LINE OF HEADERS IS NOT INCLUDED IN THE DATA (AS I AM  
ACCUSTOMED TO)
-- 1.1) WITHOUT USING pFirstLineContainsHeaders; WORKS:
on mouseUp
    put "header1" & cr & "header2" & cr & "header3" into tHeaders
    set the dgProp["columns"] of grp "DataGrid" to tHeaders
    put fld "data" into tData
    set the dgText of group "DataGrid" to tData
end mouseUp

-- 1.2) USING pFirstLineContainsHeaders: USELESS BUT WORKS :-)))
    on mouseUp
    put "header1" & cr & "header2" & cr & "header3" into tHeaders
    set the dgProp["columns"] of grp "DataGrid" to tHeaders
    put fld "data" into tData
    set the dgText[false] of group "DataGrid" to tData
end mouseUp

-- 2) IF,  FOR SOME REASON, THE LINE OF HEADERS IS INCLUDED IN THE  
DATA (FIRST LINE)
-- 2.1) WITHOUT USING pFirstLineContainsHeaders: WORKS:
on mouseUp
    put field "data" into tData
    put line 1 of tData into tHeaders
    replace tab with cr in tHeaders
    set dgProp["Columns"] of group "DataGrid"  to tHeaders
    delete line 1 of tData
    set the dgText of group "DataGrid" to tData
end mouseUp

  -- 2.2) USING  pFirstLineContainsHeaders: WORKS:
on mouseUp -- the handler from Jim
    put field "data" into tData
    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
  -------------------------------------------------
--   indeed, in all these handlers, it's possible to directly set the  
dgText of grp "datagrid" to fld "data" (but less fast, I guess,  
specially if it contains a lot of lines)
--------------------------------------------------
  AS FOR THE SYNTAX OF pFirstLineContainsHeaders
OK: set the dgText[true]
nevertheless:
put true into pFirstLineContainsHeaders
set the dgText[pFirstLineContainsHeaders] of grp "datagrid" to true
works as well, but useless, OK :-)

set the pFirstLineContainsHeaders of grp "datagrid" to true does not  
work as that is creating a custom prop; OK :-))

I am a bit slow-witted but I am beginning to understand quite what  
this pFirstLineContainsHeaders can do ;-o)))))

Thanks to both of you,

André

  
   




More information about the use-livecode mailing list