How to open pdf document on button click inside a Grid?
You can open a pdf document in a modal dialog on button click which is placed inside the grid. This can be achieved by using the Grid, Dialog, and PdfViewer components.
First, the Dialog and PdfViewer components will be initialized. The PdfViewer element will be rendered inside the Dialog element and its visibility is set as false.
<div id="dialog"> <div id="pdfViewer"></div> </div>
let dialogObj: Dialog = new Dialog({ header: "Details", showCloseIcon: true, isModal: true, visible: false }); dialogObj.appendTo("#dialog");
let viewer: PdfViewer = new PdfViewer({ serviceUrl: "https://ej2services.syncfusion.com/production/web-services/api/pdfviewer", documentPath: "document" }); viewer.appendTo("#pdfViewer"); viewer.load("PDF_Succinctly.pdf", null); |
Then, a button will be rendered inside the Grid column with click event bound to it. On button click, the modal dialog will be displayed which contains the pdf document.
<script> function onClick() { var dialogObj = document.getElementById("dialog").ej2_instances[0]; dialogObj.show(); } </script>
Output
You can find the samples here:
Conclusion
I hope you enjoyed learning about how to open pdf document on button click inside a JavaScript Grid.
You can refer to our JavaScript
Grid feature tour
page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration
specifications.
You can also explore
our JavaScript
Grid example
to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!