Page 1 of 1

DataGrid form versus table

Posted: Fri Sep 07, 2012 8:21 pm
by cusingerBUSCw5N
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?

Re: DataGrid form versus table

Posted: Sat Sep 08, 2012 1:42 pm
by bangkok
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

Re: DataGrid form versus table

Posted: Sat Sep 08, 2012 7:11 pm
by jacque
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].

Re: DataGrid form versus table

Posted: Sun Sep 09, 2012 11:40 am
by Klaus
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

Re: DataGrid form versus table

Posted: Sun Sep 09, 2012 6:50 pm
by jacque
The dgText has a key named "false"?

Re: DataGrid form versus table

Posted: Sun Sep 09, 2012 6:55 pm
by Klaus
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

Re: DataGrid form versus table

Posted: Sun Sep 09, 2012 7:05 pm
by jacque
Ok, I'll go take a look. Thanks Klaus.