Getting started with datagrid

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
pwr
Posts: 13
Joined: Thu Apr 16, 2009 8:37 pm

Getting started with datagrid

Post by pwr » Fri Jun 19, 2009 2:27 am

I'm trying out the datagrid for the first time. I want to display rows of numeric results and have encountered a trivial (I suspect) problem.

If I use the following lines of code to place two rows of data in my datagrid, I end up overwriting the first line with the second. I thought that by appending the line with 'return' I would end that line and write the second dgtext to the next line.

set the itemDelimiter to tab
put false into pFirstLineContainsHeaders
set the dgtext of group "datagridOutput" to "Saturation Conditions" & tab & empty & tab & "Liquid" & tab & "Vapor" & return
set the dgtext of group "datagridOutput" to "Pressure" & tab & "(bar)" & tab & DisplayOutputValue(Psat) & tab & DisplayOutputValue(Psat) & tab & return

Using this method to write to dgtext, how can I force the second text to write to the line below?

Thanks in advance...pwr

SparkOut
Posts: 2946
Joined: Sun Sep 23, 2007 4:58 pm

Post by SparkOut » Fri Jun 19, 2009 7:57 am

pwr wrote:I thought that by appending the line with 'return' I would end that line and write the second dgtext to the next line.
Indeed, setting dgText in a datagrid is just the same as loading a "table field" with tab and cr delimited items and rows.
The thing is, you have "set the dgText of group..." twice. Each time you set the dgText, you will set the text for the whole grid. You would be better to

Code: Select all

put "Saturation Conditions" & tab & empty & tab & "Liquid" & tab & "Vapor" & return into myDGText 
put "Pressure" & tab & "(bar)" & tab & DisplayOutputValue(Psat) & tab & DisplayOutputValue(Psat) & tab & return after myDGText
set the dgtext of group "datagridOutput" to myDGText
or other way of building up the data values to put into the grid. If there is a lot of data that you need to pull up from your stack values or a DB, then you might find it easier to work with the array version of setting the DG values. You could probably find a way to have the structure of your data store automatically mimic the array, or a simple translation routine.

pwr
Posts: 13
Joined: Thu Apr 16, 2009 8:37 pm

Post by pwr » Fri Jun 19, 2009 2:19 pm

Thank you SparkOut, that worked like a charm.

I knew one of the Revolution 'gurus' would be able to help out a 'newbie' like me....pwr :)

SparkOut
Posts: 2946
Joined: Sun Sep 23, 2007 4:58 pm

Post by SparkOut » Sat Jun 20, 2009 10:58 pm

Uh... :oops: I'm not a "newbie" maybe, but I'm not halfway up the same mountain as the "gurus" on the forum! Thanks though.

Post Reply