[SOLVED] how can i view a PDF Attachment directly from the Grid?

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
Jaymer
Posts: 2430
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

[SOLVED] how can i view a PDF Attachment directly from the Grid?

Post by Jaymer »

If I have a simple table that stores a PDF in the database, and I'm showing those lines on a grid...
normally you drill down to the Form, then click the attachment Widget and the attachment is shown in a popup.

I'd like to popup a window directly from the grid (to save a step) - lets say from a row operation button (or I could get fancy and trap a click on a grid column)

If it was an image, and it was in the filesystem, I could popup a window with an html cell using <img> and show the image like that.

How can I show the PDF directly from the grid?
Screen Shot 2021-11-22 at 11.41.26 AM.png
Screen Shot 2021-11-22 at 11.41.26 AM.png (75.26 KiB) Viewed 10271 times
Without having to bring up a form and clicking in the widget:
Screen Shot 2021-11-22 at 11.42.54 AM.png
Screen Shot 2021-11-22 at 11.42.54 AM.png (69.71 KiB) Viewed 10271 times
Last edited by Jaymer on Thu Dec 02, 2021 8:55 pm, edited 1 time in total.
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
johntalbott
Posts: 619
Joined: Wed Jun 17, 2015 11:16 pm
Location: Omaha, Nebraska
Contact:

Re: how can i view a PDF Attachment directly from the Grid?

Post by johntalbott »

AwareApp.viewDocument might do what you are looking for.

To test it out, you could use an operation button that executes JavaScript with some hardcoded values.

AwareApp.viewDocument (BOName, BOID, BOAttributeStoringPDF)
VocalDay Solutions - Agility - Predictability - Quality

We specialize in enabling business through the innovative use of technology.

AwareIM app with beautiful UI/UX - https://screencast-o-matic.com/watch/crfUrrVeB3t
Jaymer
Posts: 2430
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: how can i view a PDF Attachment directly from the Grid?

Post by Jaymer »

johntalbott wrote: Mon Nov 22, 2021 7:03 pm To test it out, you could use an operation button that executes JavaScript with some hardcoded values.
Yes, this works quite nicely:
Screen Shot 2021-11-22 at 6.09.06 PM.png
Screen Shot 2021-11-22 at 6.09.06 PM.png (31.04 KiB) Viewed 10258 times

But I need to dynamically get the ID in there. Tried several things.
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
johntalbott
Posts: 619
Joined: Wed Jun 17, 2015 11:16 pm
Location: Omaha, Nebraska
Contact:

Re: how can i view a PDF Attachment directly from the Grid?

Post by johntalbott »

This should do the trick.

Code: Select all

const id = parser.m_highlightedRow.refValue.split(":")[1];

AwareApp.viewDocument ("ReqLines", id, "ReqAttachment");
VocalDay Solutions - Agility - Predictability - Quality

We specialize in enabling business through the innovative use of technology.

AwareIM app with beautiful UI/UX - https://screencast-o-matic.com/watch/crfUrrVeB3t
Jaymer
Posts: 2430
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: how can i view a PDF Attachment directly from the Grid?

Post by Jaymer »

yep, thx!
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
karelh
Posts: 86
Joined: Wed Oct 26, 2016 10:20 pm

Re: how can i view a PDF Attachment directly from the Grid?

Post by karelh »

Hey Jaymer,

We simply have a process that runs the following command.
DOWNLOAD DOCUMENT BO.DocAttr

If its a PDF it will open in the browser.
Jaymer
Posts: 2430
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: how can i view a PDF Attachment directly from the Grid?

Post by Jaymer »

Thx K
Yes, thats more what I was originally thinking. I rarely (if ever) use DOWNLOAD DOCUMENT. Early on, I was thinking I'd make a report with the Document inside it, then DISPLAY DOCUMENT. Less than ideal. So I asked here thinking I was missing something obvious - which I was.

I tried it, but I like it my original way... for these reasons:
1) Even on my machine, it downloaded the file, requiring a click to open it. Would hate to hassle with a group of users and make them install the viewer plugin (or whatever settings allow it to auto display)
2) Opened in new tab - vs. Popup. I actually like the popup in this case to briefly view the PDF.

My Code (with help from John):

Code: Select all

var theID = parser.m_highlightedRow.refValue.split(":")[1];
AwareApp.viewDocument ('ReqLines', theID , 'ReqAttachment')
--> JaymerTip Display PDF directly from Grid
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
Post Reply