Data grids and globals as data sources

Whether you're using the Standard or Professional Edition of Quartam Reports, this is the place to ask general questions about using this industry-level reporting tool for LiveCode.
Locked
NingImport
Posts: 87
Joined: Sun Jul 18, 2010 5:23 pm

Data grids and globals as data sources

Post by NingImport » Sun Jul 18, 2010 7:33 pm

Data grids and globals as data sources

Posted by Alex Adams on November 20, 2009 at 10:43pm

I just got my copy of Quartam Reports Professional. Now I am ready to add printing to an app that is about to go out to beta.

What I need is instructions on print reports from the contents of a data grid and how to reference globals in the report.

The theory and layout for the reports is clear. It's just that in this case the information needed for a report at the time of printing has already been taken from databases and exists in its entirety in data grid, globals, and form fields.

=====

Reply by Jan Schenkel on November 24, 2009 at 7:22am

Hi Alex,

Let's start with the easiest question: globals.

If you're printing a report using the 'simple' commands for stacks, database cursors or automated queries, then all you need to do is prvode a comma-separated list of global variable names as the firth parameter. Example:
##
on mouseUp
put the effective filename of this stack into theLayoutPath
set the itemDelimiter to slash
put "Layouts/MyLayout.qrl" into item -1 of theLayoutPath
put the short name of this stack into theStackName
put true into thePreviewFlag
put "all" into theCardRange
put "gUserId,gUserName,gUserLevel" into the GlobalNamesList
qrtReports_PrintReportForStack theLayoutPath, theStackName, thePreviewFlag, theCardRange, theGlobalNamesList
end mouseUp
##
Then you can use gUserId and gUserName as part of the expressions on your layout. You could have a data field with expression: gUserId && "-" && gUserName
You can also use them in printing condition expressions: gUserLevel > 2

If you're scripting your own data broker (which you'll have to, in order to print the contents of a datagrid, then you simply declare them at the top of your script
##
global gUserId, gUserName, gUserLevel
local sDgData, sRowData, sRowCount, sRowIndex
on mouseUp
-- fetch the datagrid content and prepare for printing
put the dgData of group "MyDatagrid" into sDgData
put item 2 of the extents of sDgData into sRowCount
put 0 into sRowIndex
PrepNextRow
-- prepare the other parameters for the printing library
put the effective filename of this stack into theLayoutPath
set the itemDelimiter to slash
put "Layouts/MyLayout.qrl" into item -1 of theLayoutPath
put the long id of me into theDataBroker
put true into thePreviewFlag
qrtReports_PrintReport theLayoutPath, theDataBroker, thePreviewFlag
end mouseUp
-- helper commands
private command PrepNextRow
add 1 to sRowIndex
put sDgData[sRowIndex] into sRowData
end PrepNextRow
-- data broker callbacks
function qrtReports_EndOfReport
return sRowIndex > sRowCount
end qrtReports_EndOfReport
on qrtReports_MoveNextDetail
PrepNextRow
end qrtReports_MoveNextDetail
function qrtReports_ValueOfExpression pExpression
put pExpression into tExpression
replace "" with quote in tExpression
return value(tExpression)
end qrtReports_ValueOfExpression
##
Now in your layout you can use the globals as described earlier; and to get at the datagrid content for the current row, you can use an expresison like: sRowData["LastName"] & comma && sRowData["FirstName"]
Bear in mind that if you have used behaviours to reformat the raw data (for instance to turn a timestamp into a readable system data), you'll need to use functions to do these conversions on your print layout, as part of the expression: TimestampToDate(sRowData["LastUpdate"])
will work, as long as the TimestampToDat fun ction is defined somewhere in the message path, looked at from the perspective of your data broker script (its card, its stack,...)

HTH,

Jan Schenkel.
--
Quartam Reports & PDF Library for Revolution
www.quartam.com

=====

Reply by Alex Adams on November 25, 2009 at 12:21am

Jan,

Thanks for taking such care in your response.

I have just finished the printing development for this little app I'm bringing to distribution. It's printing 12 different record forms and 13 different lists.

I got into the data broker scheme, and did them all that way. It was straight forward, once I got it integrated into the app, using it's existing data management handlers. I am admiring the work you did on this product. The integration into rev is wonderful.

I discovered a behavior I would like to work around if you have any ideas. In a one line detail section, I find that if I have more than one field designated to expand vertically, the results will be chaos. If I keep it to only one column, then everything works fine. Do you have any ideas about to correct this?

Thank you for this fine tool,

--
Alex Adams

hawkVision — tools for solving Wicked Problems

(a)2 Technology Partners, Inc.
831-726-8013
alex@a2tecnology.com
www.a2technology.com
www.promisstudio.com
universalconnector.wordpress.com

=====

Reply by Jan Schenkel on November 28, 2009 at 5:28pm

Hi Alex,

It's always good to hear when users successfully integrate Quartam Reports with their projects. Of course, I tend to think the library works very well and makes reporting a lot easier, especially if you're coming from a database background - but compliments about its workings are an excellent motivator :-)

Regarding the multiple stretching data fields, could you send me a simple test scenario? Then I can track down why it isn't behaving properly.

TIA,

Jan Schenkel
--
Quartam Reports & PDF Library for Revolution
www.quartam.com
===== The above post was imported from the old forum hosted at quartam.ning.com =====

Locked