jQWidgets Forums
jQuery UI Widgets › Forums › Grid › How can I print the content of a jqxWindow popup
Tagged: print jqxwindow
This topic contains 3 replies, has 2 voices, and was last updated by softboy99 8 years, 10 months ago.
-
Author
-
I am using the jqWidget Grid and edit popup window. I want to be able to open the popup window and print the content of the popup window. Is this possible and if so how do I go about doing it?
Below is the code that I’ve been working on. When I click the button in the grid to open the popup window the window opens and when I click the Print button to print the contents of the window but if after printing the popup I open a different popup window to print and click the Print button the previous record is displayed in the printer dialog window. If I cancel the print the new record is displayed in the print dialog window. I a guessing I am not getting the data correctly. Thanks in advance for your help.
$("#printPopup").click(function () { var newWindow = window.open('', '', 'width=400, height=700'), document = newWindow.document.open(), pageContent = '<!DOCTYPE html>\n' + '<html>\n' + '<head>\n' + '<meta charset="utf-8" />\n' + '<title>jqWidgets</title>\n' + '</head>\n' + '<body>\n' + '<div style="width:320px">' + '<img height="500" src = "http://mywebsite.com/users/'+username+'/'+dataRecord.photo +'"</div>'+ '<div style=font-size:11pt;width:320px"><strong>Category</strong>: '+ dataRecord.category+'<br />'+ '<strong>Date</strong>: ' + dataRecord.date + '<br />' + '<strong>Title</strong>: ' + dataRecord.name + '<br />' + '<strong>Cost</strong>: $' + dataRecord.cost.toFixed(2) + '<br />' + '<strong>Purpose</strong>: ' + dataRecord.purpose + '<br />' + '<strong>Tag</strong>: ' + dataRecord.tagName + '<br />' + '<strong>Note</strong>: ' + dataRecord.note + '<br /></div>' + '</body>\n</html>'; document.write(pageContent); document.close(); newWindow.print(); });
I came up with a solution to the problem which is to reload the browser window when the x is clicked in the upper right corner of the popup window.
Below is the code that I added to accomplish the browser reload.
Not that happy with my solution as it refresh the browser window after every opening and closing of the popup window.
If anyone knows of a better solution please post itThanks
// refresh browser window. $("div.jqx-window-close-button").click(function(){ window.location.reload(); });
I came up with a better solution. Instead of opening a popup with a button to print the popup, I changed the button on the grid so that it opens the print dialog with the contents of the row formatted in HTML ready to print.
This totally solved my problem.
Love your widgets!
Hi wsessonms:
could you please give out your sample code ? thanks. -
AuthorPosts
You must be logged in to reply to this topic.