NetTalk Central

Author Topic: Printing directly from a Browse Button...  (Read 4074 times)

Windflite

  • Newbie
  • *
  • Posts: 1
    • View Profile
    • Email
Printing directly from a Browse Button...
« on: September 11, 2012, 03:44:06 AM »
Quick follow up question regarding printing.  

Currently I'm able to print by using a  Memory form 'Save' button renamed for printing.  My implementation is;
1) define the .pdf name in the ValidateUpdate Start embed;

  !!! Define PDF name, call report !
  p_web.ssv('MyPDFName','$$$' & format(random(1,99999),@n05) & '.pdf')
  reportpage = '\web\reports\' & p_web.gsv('MyPDFName')   ! $$$test.pdf'
  reporturl  = LongPath() & reportpage
  p_web.ssv('reportlink','Click to Open Report')
  p_web.ssv('reporturl',clip(sub(p_web.requestReferer,1,instring('BacklogDisplayForm',p_web.requestReferer,1,1)-1) & 'reports/' & p_web.gsv('MyPDFName')))

  if exists(reporturl) then remove(reporturl).

  !!! call Source Coded Report Here---pass pdf filename.
  bkl_report('Summary',p_web.gsv('MyDealerNumber'),p_web.gsv('MyPDFName'))

2) Set the NetWebForm 'Save' button destination to be 'ViewReport' on a blank target..

So far so good.  Next step is to print a 'row related' report directly from a button in a browse.   My 5 hour failed saga today in extending the above ability to a button in a row has been a frustrating experience to say the least.  I simply need to understand how to call a report (netwebpage on a blank frame with a passed pdf name) from a button (preferable the std 'print' button) and have the ability when the button is pressed to capture the row info, call a source procedure to generate the pdf and finally display the pdf by calling the ViewReport page.

So, In a NetWebBrowse, is their embed point (or points!) for a 'std' print button so that I can;

a) Set my Session Variables with the row info I need. (Following currently in the 'User Clicked on a Row' embed.)
ie.
  do OpenFilesB                             ! Set session variables for filter on next screen..
  b_trk:ulinky = p_web.GSV('b_trk:ulinky')
  myresult# = p_web._GetFile(b_trk,b_trk:ulinky_key)
  p_web.ssv('MyTruckCode',b_trk:trk_cde)
  p_web.ssv('MyShipDate',b_trk:trk_dte)
  do ClosefilesB

b) Generate the .pdf name with the following... (tried in EIP embed...but it fires AFTER the 'on click' URL calls for std and other buttons in a browse)

  p_web.ssv('MyPDFName','$$$' & format(random(1,99999),@n05) & '.pdf')
  reportpage = '\web\reports\' & p_web.gsv('MyPDFName')   ! $$$test.pdf'
  reporturl  = LongPath() & reportpage
  p_web.ssv('reportlink','Click to Open Report')
  p_web.ssv('reporturl',clip(sub(p_web.requestReferer,1,instring('ShippingDisplay',p_web.requestReferer,1,1)-1) & 'reports/' &      p_web.gsv('MyPDFName')))

  if exists(reporturl) then remove(reporturl).


b) Call the source procedure that generates the pdf for display.  This is not a web enabled page.
  myreport((p_web.gsv('MyTruckDate')',p_web.gsv('MyTruckCode'),p_web.gsv('MyPDFName'))


c)  Finally call the ViewReport procedure on a blank frame?
   ?????  (Not sure where to put this!  Tried the 'on clicked' embed, but can't get data filled in before it calls ViewReport.))

I know there is a simple answer and thx in advance for your help!

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Printing directly from a Browse Button...
« Reply #1 on: September 11, 2012, 05:17:03 AM »
Hi Andy,

>> Next step is to print a 'row related' report directly from a button in a browse.   My 5 hour failed saga today in extending the above ability to a button in a row has been a frustrating experience to say the least.

everything needs to be part of the URL. In other words;
>> Set my Session Variables with the row info I need. (Following currently in the 'User Clicked on a Row' embed.)

will not work. Because the link has already been clicked when that code runs. Rather you need to extend the URL on the button - usually just by ticking on the option to "Include the RowId". Then the Unique Id for the browse will be in the Value queue, and can be retrieved with p_web.GetValue at the destination.

At that point you can read whatever you like from the database etc. You have the row id.
remember also the code to make the report etc goes into the Destination page procedure, not the browse button.

cheers
Bruce


Jim A

  • Full Member
  • ***
  • Posts: 203
    • View Profile
    • Email
Re: Printing directly from a Browse Button...
« Reply #2 on: September 12, 2012, 05:57:07 PM »
I am esp. interested in this.  Let's say the Browse contains Inventory items.  One of the columns is "Inv:StockNo" -- my report will print the specifications for one Inventory item.  I have a Print Button on each row and want to know the Inv:StockNo of that row so I can filter on it.  How is this done, please?

Thanks!

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Printing directly from a Browse Button...
« Reply #3 on: September 12, 2012, 10:24:35 PM »
Hi Jim,

It's worth thinking about this for a second.

when the browse generates an HTML page is created and set to the browser. The HTML contains a "Table". It also contains buttons.

BUT there is no "browse procedure" running at the server side. While the user is looking at the page the server is just doing nothing. When the user clicks on the button, on the web page, the page has to formulate a new request and send it to the server.

So the ID it passes through is the Row id for the row the user clicked on. That's all it sends, just the row id. It doesn't send the whole "contents of the row".

So, when you create a button, (an "other" button) you have the option to "include row id". If this is on then the "unique id for the row" is set in the Value queue.

So, in your case, assuming Inv:Id is the unique id, then p_web.GetValue('Inv:Id') will return that Id. You can then use that to load the record if you want to see other values in the row.

cheers
Bruce

Jim A

  • Full Member
  • ***
  • Posts: 203
    • View Profile
    • Email
Re: Printing directly from a Browse Button...
« Reply #4 on: September 13, 2012, 04:05:46 AM »
Thanks Bruce.  The more the table looks like a browse, the easier it is to forget that it's not a desktop app.