text of header in dataGrid
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
text of header in dataGrid
Hi,
I don't know how to put the text into header dataGrid table. I tried code:
set the dgText [true] of group "myDGname" to myTextHeader
This line doesn' make anything but the line code:
set the dgText of group "myDGname" to myTextHeader
This line code put text from myTextHeader into data grid tablet "myDGname".
I tried:
true as "true"
true into variable and variable into []
I don' know what I do wrong. Can enybody help me?
Oldrich
I don't know how to put the text into header dataGrid table. I tried code:
set the dgText [true] of group "myDGname" to myTextHeader
This line doesn' make anything but the line code:
set the dgText of group "myDGname" to myTextHeader
This line code put text from myTextHeader into data grid tablet "myDGname".
I tried:
true as "true"
true into variable and variable into []
I don' know what I do wrong. Can enybody help me?
Oldrich
Re: text of header in dataGrid
Hi Oldrich,
1. welcome to the forum!
2. Why is everyone starting with the most complex object, the DATAGRID, in Livecode?
This is a rhetorical question!
The parameter to -> dgtext[TRUE/FALSE] does NOT change the header labels nor does it add or remove columns! See below for more info...*
To do so you need to:
...
set the dgprop["column labels"] of grp "your datagrid here..." to CR_delimited_list_of_header_names
...
From the datagrid docs:
read it up a couple of times, work throught the examples and read it up again a couple of times when you need to use it in LC, like I do
Best
Klaus
1. welcome to the forum!
2. Why is everyone starting with the most complex object, the DATAGRID, in Livecode?
This is a rhetorical question!
The parameter to -> dgtext[TRUE/FALSE] does NOT change the header labels nor does it add or remove columns! See below for more info...*
To do so you need to:
...
set the dgprop["column labels"] of grp "your datagrid here..." to CR_delimited_list_of_header_names
...
From the datagrid docs:
Do yourself a favour and download the docs as PDF here: http://lessons.livecode.com/m/datagrid, TINY link under TOPICS on the left,...
dgText
- get the dgText [pIncludeColumnNames]
- set the dgText [pFirstLineContainsHeaders] of group "DataGrid" to pText
- The data grid works with arrays behind the scenes but in the interest of making life easier for some folks there is a dgText property. The dgText property always reflects the same value as the dgData but in tab delimited form.
pText is assumed to be a collection of data where each row is delimited by the return character and each item is delimited by a tab. You can map each item of each line in pText to a particular key in an array (and thus a table column) by passing in true for pFirstLineContainsHeaders. If true then the data grid will extract the first line of pText and use the values for the internal key/column names. The default value for pFirstLineContainsHeaders is false.
If you set the dgText of a data grid table then all data will be imported and assigned to the appropriate column depending on the value of pFirstLineContainsHeaders. Normally you should set this property to true and provide the header that maps each item of each line to a specific column. Note that if pFirstLineContainsHeaders is true then the columns must already exist in your data grid table in order to be displayed.
If pFirstLineContainsHeaders is false then the columns property of the data grid is used for mapping. For example, the first item of a line of pText would be assigned to the column that appears on the first line in the columns property of the data grid. If line 1 of pText contains more items than there are columns in the table then new columns are added. Any new columns are named "Col 1", "Col 2", etc.
...
read it up a couple of times, work throught the examples and read it up again a couple of times when you need to use it in LC, like I do
Best
Klaus
Re: text of header in dataGrid
Will move this thread to the "Beginner" forum, since "DataGrid Helper" is in fact a third-paty add-on to Livecode:
http://www.aslugontheroad.com/ourproducts
So the forum title might be a bit misleading
http://www.aslugontheroad.com/ourproducts
So the forum title might be a bit misleading
Re: text of header in dataGrid
dgtext can't set the column labels.
If you use dgText[true] , you declare that the first line is the column name to use to assign the data.
So if your datagrid has 3 columns: col1, col2 and col3
You can legally use:
########CODE#######
on mouseUp
put "col3" & TAB & "col2" & return & "a3" & TAB & "a2" into temp
set the dgtext[true] of group 1 to temp
end mouseUp
#####END OF CODE#####
Because the first line is used just to map data. As explained here: http://livecode.wikia.com/wiki/Datagrid ... umn_labels you have to use the dgProp["column labels"], for example:
########CODE#######
set the dgProp["column labels"] of group "myTable" to ("Column 1" & return & "My Perfect Column 2")
#####END OF CODE#####
If you use dgText[true] , you declare that the first line is the column name to use to assign the data.
So if your datagrid has 3 columns: col1, col2 and col3
You can legally use:
########CODE#######
on mouseUp
put "col3" & TAB & "col2" & return & "a3" & TAB & "a2" into temp
set the dgtext[true] of group 1 to temp
end mouseUp
#####END OF CODE#####
Because the first line is used just to map data. As explained here: http://livecode.wikia.com/wiki/Datagrid ... umn_labels you have to use the dgProp["column labels"], for example:
########CODE#######
set the dgProp["column labels"] of group "myTable" to ("Column 1" & return & "My Perfect Column 2")
#####END OF CODE#####
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
-
- VIP Livecode Opensource Backer
- Posts: 9752
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: text of header in dataGrid
I have a long standing stupid joke.
"I use dataGrids, but do not understand them.
@MaxV. I do not understand your handler. Only this:
sets the text of the DG, and the "col1..." stuff appears in the first line. If I use your "dgtext[true] construction, nothing happens at all.
Craig Newman
"I use dataGrids, but do not understand them.
@MaxV. I do not understand your handler. Only this:
Code: Select all
on mouseUp
put "col3" & TAB & "col2" & return & "a3" & TAB & "a2" into temp
set the dgtext of group 1 to temp
end mouseUp
Craig Newman
Re: text of header in dataGrid
Note that set dgText[true] acts differently of put dgText[true].dunbarx wrote: @MaxV. I do not understand your handler. Only this:sets the text of the DG, and the "col1..." stuff appears in the first line. If I use your "dgtext[true] construction, nothing happens at all.Code: Select all
on mouseUp put "col3" & TAB & "col2" & return & "a3" & TAB & "a2" into temp set the dgtext of group 1 to temp end mouseUp
Craig Newman
This code for example:
Code: Select all
put the dgText[true] of group "DataGrid"
Code: Select all
Col 1 Col 2 Col 3
a1 b1 c1
a2 b2 c2
Code: Select all
Col 3 Col 1 Col 2
c1 a1 b1
c2 a2 b2
Code: Select all
set the dgText[true] of group "DataGrid" to temp
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w