Page 1 of 1

Getting started with datagrid

Posted: Fri Jun 19, 2009 2:27 am
by pwr
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

Posted: Fri Jun 19, 2009 7:57 am
by SparkOut
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.

Posted: Fri Jun 19, 2009 2:19 pm
by pwr
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 :)

Posted: Sat Jun 20, 2009 10:58 pm
by SparkOut
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.