Printing DATAGRID need Help

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
blairetabay
Posts: 34
Joined: Mon Feb 24, 2014 10:12 am

Printing need Help

Post by blairetabay » Mon Feb 24, 2014 10:47 am

Good day!


Im new in livecode.

i have a serious problem regarding with printing im using a quartam report builder.

i have a database and inside my database i have a table and all the value i have in my table i populate in a datagrid. all i need is to print all the value inside my datagrid.

i search for some of the sample but it does not work.

datagrid name is dgGrid
quartam field expression is sample["sample1"]
quartam field expression is sample["sample2"]
quartam field expression is sample["sample3"]
quartam field expression is sample["sample4"]

here is my code

Code: Select all


  add 1 to printCount
   
   if (printCount > 0) Then   

  --FETCH the next row from the Data Grid
      put the dgDataOfIndex[printCount] of the group "dgGrid" into tDataRow
      put the dgDataOfIndex  of the group "dgGrid" into tDataRow
     
           
            put tDataRow["Col 3"] into sample["sample1"]
            put tDataRow["Col 3"] into sample["sample2"]
            put tDataRow["Col 3"] into sample["sample3"]
            put tDataRow["Col 4"] into sample["sample4"]
      
            
   end if   
  



MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

Re: Printing need Help

Post by MaxV » Mon Feb 24, 2014 5:12 pm

You can print a window with:

Code: Select all

print this card
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

blairetabay
Posts: 34
Joined: Mon Feb 24, 2014 10:12 am

Re: Printing need Help

Post by blairetabay » Tue Feb 25, 2014 2:24 am

hi MaxV

i'm using the demo of quartam is there any another way that I could print? or a hard coding for the printing of LC


blairetabay

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Printing need Help

Post by Simon » Tue Feb 25, 2014 3:45 am

Hi blairetabay,
Are you speaking of "printing" to screen or hardcopy?
I don't see any print commands in the code you provided.

qrtReports_PrintReportFromStack tLayoutFile, tStackName, tShowPreview
is the code from the example here;
http://users.telenet.be/quartam/reports/examples.html

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

blairetabay
Posts: 34
Joined: Mon Feb 24, 2014 10:12 am

Re: Printing need Help

Post by blairetabay » Tue Feb 25, 2014 4:11 am

Simon,

I have already that one, I did not include in my code.I only posted is in the datagrid that will get one column and its row because i want to print per column inside my datagrid. from this

Code: Select all

put revdb_columnnames(sCursorID) into tColumnNames

repeat for each item tColumnName in tColumnNames
put revdb_columnbyname(sCursorID,tColumnName) into \
sRecordAsArray[tColumnName]
end repeat
-- retrieve the data from our supplier website
put "sample URL what ever=" & \
URLEncode(sRecordAsArray["article_id"]) into tRemoteURL
put URL tRemoteURL into sRecordAsArray["delivery_days"]
end PrepareRecordData


from the above code i make a datagrid that will read each column and will print per column.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Printing need Help

Post by Simon » Tue Feb 25, 2014 4:26 am

Hi blairetabay,
I'm sorry I don't understand what you are asking for.
Maybe someone else will know.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

blairetabay
Posts: 34
Joined: Mon Feb 24, 2014 10:12 am

Re: Printing need Help

Post by blairetabay » Tue Feb 25, 2014 5:17 am

Simon,

:cry:

im only asking how to print all the data inside my datagrid.

:idea:

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Printing need Help

Post by Simon » Tue Feb 25, 2014 5:24 am

OK short answer;
put the data into a field and then "print this card".

But that was said above???

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

blairetabay
Posts: 34
Joined: Mon Feb 24, 2014 10:12 am

Re: Printing need Help

Post by blairetabay » Tue Feb 25, 2014 8:04 am

Simon,


I know that one the print this card.
all i want is the data inside my datagrid to be printed. not the card itself.

i'm working on the standalone windows app

here is my code

Code: Select all

  PrepareRecordData
   -- get ready to print
   local tLayoutFile, tDataBroker, tShowPreview
   put AbsolutePath ("tabaySample.qrl") into tLayoutFile
   put the long ID of me into tDataBroker
   put true into tShowPreview
   -- print the report
   qrtReports_PrintReport tLayoutFile, tDataBroker, tShowPreview
   -- clean up after printing
   get revdb_closecursor(sCursorID)
   get revdb_disconnect(sConnectionID)
end mouseUp

on PrepareRecordData
   ## PREPARE THE DATA FROM THE CURRENT RECORD FOR PRINTING
   
   -- define the variables
   
   local tColumnNames, tColumnName,tDataRow
   -- copy the contents of the current record into the array
   -- column per column
   put revdb_columnnames(sCursorID) into tColumnNames
   
   repeat for each item tColumnName in tColumnNames
      put revdb_columnbyname(sCursorID,tColumnName) into \
            sRecordAsArray[tColumnName]
   end repeat
   
---- retrieve the data from our supplier website
   --   put "url something here=" & \
         --         URLEncode(sRecordAsArray["article_id"]) into tRemoteURL
   --put URL tRemoteURL into sRecordAsArray["delivery_days"]
   

--quartam empression is sample["sample1"] and so on.......

   put the GetDataOfLine   of the group "dgGrid" into tDataRow
   #put the dgHilitedIndexes    of the group "dgGrid" into tDataRow
      put (tDataRow["recordNum"]) into sample["sample1"]
      put (tDataRow["PatientName"]) into sample["sample2"]
      put (tDataRow["Col 3"] )into sample["sample3"]
      put (tDataRow["Col 4"] )into sample["sample4"]
        
   
   #print this card
      
    
   
end PrepareRecordData



-- Quartam Reports Callback Handlers and Functions

function qrtReports_EndOfReport
## QR :: RETURN TRUE IF THE END OF THE REPORT HAS BEEN REACHED
-- we've reached the end if we've passed our last record
return (sCurrentRecord > sRecordCount)
end qrtReports_EndOfReport

on qrtReports_MoveNextRecord
## QR :: PREPARE EVERYTHING FOR PRINTING THE NEXT RECORD
-- update the sCurrentRecord local variable
add 1 to sCurrentRecord
-- move to the next record in the cursor
get revdb_movenext(sCursorID)
-- and prepare the record data
PrepareRecordData
end qrtReports_MoveNextRecord

function qrtReports_ValueOfExpression pExpression
## QR :: EVALUATE THE EXPRESSION AND RETURN THE RESULT
-- workaround for limitation in LiveCode engine
local tExpression
put pExpression into tExpression
replace "<QUOTE_REPLACEMENT>" with quote in tExpression
return value(tExpression)
end qrtReports_ValueOfExpression

function AbsolutePath pRelativePath
  ## this helper function looks for files from the directory where the stack is saved
  put the effective filename of this stack into tAbsolutePath
  set the itemDelimiter to "/"
  put pRelativePath into item -1 of tAbsolutePath
  return tAbsolutePath
end AbsolutePath


any help is recomended for this.

thank you guys in advance :D
:idea:

MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

Re: Printing need Help

Post by MaxV » Tue Feb 25, 2014 12:31 pm

OK, you just need a print into rectangle commands, it's explained in the User Guide pdf in Livecode. You can read it form Help -> User Guide
8.10 Printing a Layout
If you need to print a more complex layout than allowed with the basic print card command or text printing commands (described above), you can use the print card into rect syntax to create any sort of layout you choose:

Code: Select all

 print card from topLeft to rightBottom into pageRect
  • The topLeft is the top left coordinate of the current card to start printing at.
  • The rightBottom is the bottom right coordinate of the current card to stop printing at.
  • The pageRect is the rectangular area on the paper to print into.
So, now you know how to print just a part of a card. Otherwise, if your datagrid were huge, you could create a temporary stack; where every card is a part of the datagrid and then launch

Code: Select all

print this stack
This way you can print very big tables, but you can split table over many pages.
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

blairetabay
Posts: 34
Joined: Mon Feb 24, 2014 10:12 am

Printing DATAGRID need Help

Post by blairetabay » Tue Feb 25, 2014 5:40 pm

I'm a beginner in LC i have a serious problem regarding with printing

i try using a print this card the problem with print this card is only the value inside the card. How about i have a datagrid and the data is more than one page of printing.

im developing a standalone app.

i found this code from the example an i dont know how to use it

Code: Select all

on PrepareRecordData
   ## PREPARE THE DATA FROM THE CURRENT RECORD FOR PRINTING
   
   -- define the variables
   
   local tColumnNames, tColumnName,tDataRow
   -- copy the contents of the current record into the array
   -- column per column
   put revdb_columnnames(sCursorID) into tColumnNames
   
   repeat for each item tColumnName in tColumnNames
      put revdb_columnbyname(sCursorID,tColumnName) into \
            sRecordAsArray[tColumnName]
   end repeat

 
--- retrieve the data from our supplier website
      put "http:url something here=" & \
            URLEncode(sRecordAsArray["article_id"]) into tRemoteURL
   put URL tRemoteURL into sRecordAsArray["delivery_days"]
   
here is my code for the datagrid to able to print please help me on this

recordNum is datagrid row name
sample["sample1"] is a quartam expression

Code: Select all


 put the getDataOfIndex of the group "dgGrid" into tDataRow
   put tDataRow, "recordNum" into sample["sample1"]

thank you guys


blaireTabay

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Printing DATAGRID need Help

Post by Klaus » Tue Feb 25, 2014 5:50 pm

I am afraid, very few folks here will use QuartamReports, so this is a very special problem
that maybe you should ask for in the Quartam forum?
http://forums.quartam.on-rev.com

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Printing DATAGRID need Help

Post by Klaus » Tue Feb 25, 2014 6:30 pm

OK, I found a way to "Merge" your threads, I think this is a good solution :D

blairetabay
Posts: 34
Joined: Mon Feb 24, 2014 10:12 am

Re: Printing DATAGRID need Help

Post by blairetabay » Wed Feb 26, 2014 3:41 pm

Klaus,


the link that you given is not available for quartam forum.

many thanks anyway.

best

blaireTabay

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Printing DATAGRID need Help

Post by Klaus » Wed Feb 26, 2014 4:04 pm

Hi Blaire,

the link is working for me!? :shock:


Best

Klaus

Post Reply