DataGrid form versus table

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
cusingerBUSCw5N
Posts: 339
Joined: Wed Jul 11, 2012 9:24 pm

DataGrid form versus table

Post by cusingerBUSCw5N » Fri Sep 07, 2012 8:21 pm

I have successfully created Datagrid tables using an outside database. It uses tab-delimited information (actually, I modify the information once it reaches LiveCode to make it tab-delimited).

Now, I am trying to format them using Datagrid forms. And it doesn't work. I don't know why... Once it works in a table, I switch it to forms, then set up the row template and row behavior. That's all I do...

Then, to make me crazy, once it fails in Datagrid forms, it no longer works when I switch it back to a table - so I have to start all over again.

Here is the code that works in table, but not in forms:

global cx
put "http://mywebsite/forum.cfm?cx=" & cx & "" into turl
put url(turl) into theData_forum

replace "xyz" with return in theData_forum
replace "usetab" with tab in theData_forum
--add data
put false into firstLineAreNames
set the dgText[firstLineAreNames] of group "DataGrid top" to theData_forum
put the width of this stack into tStackWidth
put the dgDataOfLine[1] of group "DataGrid top" into theDataZ
if theDataZ["topic"] is empty then
put 1 into theLine
send "DeleteLines theLine" to grp "DataGrid top"
end if

What am I doing wrong?

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Re: DataGrid form versus table

Post by bangkok » Sat Sep 08, 2012 1:42 pm

cusingerBUSCw5N wrote: send "DeleteLines theLine" to grp "DataGrid top"
This is a mistake : with those quotes, LiveCode will send "DeleteLines theLine", instead of DeletesLines 1 [the content of the variable theLine]

Try instead :

Code: Select all

send "DeleteLines "&&theLine to grp "DataGrid top"
Or :

Code: Select all

 dispatch DeleteLines to grp ""DataGrid top"" with  theLine

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7237
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: DataGrid form versus table

Post by jacque » Sat Sep 08, 2012 7:11 pm

bangkok wrote:
cusingerBUSCw5N wrote: send "DeleteLines theLine" to grp "DataGrid top"
This is a mistake : with those quotes, LiveCode will send "DeleteLines theLine", instead of DeletesLines 1 [the content of the variable theLine]
Actually, I do that sort of thing a lot, LiveCode should evaluate the parameter correctly. But I'm not sure about this part:
put false into firstLineAreNames
set the dgText[firstLineAreNames] of group "DataGrid top" to theData_forum
Won't that produce an invalid key for dgText? It evaluates to dgText[false].
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: DataGrid form versus table

Post by Klaus » Sun Sep 09, 2012 11:40 am

You can set the dgTEXT of grp "datagrid" as often as you want,
but this will only work (= visible resutls) with a datagrid of type TABLE!

If you have a FORM datagrid, you need to supply an array:
set the dgDATA of grp "datagrid" to tArray

And you need to script a custom behavior so the datagrid knows what data of the array have to go where.
This is a complex best and I highly recommend to work through the examples in the datagrid documentation PDF.
Get it here: http://lessons.runrev.com/m/datagrid

At least this is nothing that can be handled here in the forum in a couple of sentences 8)

@Jacqueline
dgText[false] = dgtext = Correct syntax, no error or something.


Best

Klaus

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7237
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: DataGrid form versus table

Post by jacque » Sun Sep 09, 2012 6:50 pm

The dgText has a key named "false"?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: DataGrid form versus table

Post by Klaus » Sun Sep 09, 2012 6:55 pm

Hi Jaqueline,
jacque wrote:The dgText has a key named "false"?
yep, that is the default, so this is correct syntax, although unneccessary, just leave it empty in that case :)

From the DataGrid docs:
...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.
...

Best

Klaus

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7237
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: DataGrid form versus table

Post by jacque » Sun Sep 09, 2012 7:05 pm

Ok, I'll go take a look. Thanks Klaus.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”