Thinking someone else has already done this - so why recreate the wheel? I want the print button to open the print dialogue on the user’s computer - to print the current document displayed on screen - without printing the buttons, etc. that are shown on screen. The standard print button in SC opens a window asking what I want to print and then displays the text on its own page - leaving the user to have to figure out how to print that. New to all this so could use a little help. I watched a video that Carlos did the other day (Rental Management) and saw that he created a javascript button to “go back” - so thought I could do the same with print.
Option 1 - Using SC Button (this works - but also prints the buttons on the toolbar of the grid)
Create a Button - jsPrint - and put this code there:
window.print() ;
Option 2 - Using HTML template - works flawlessly and only prints the document - not the buttons - but the buttons are a part of the html document and not the grid; I would rather use the buttons in SC so that things are consistently styled the same.
<head>
<!-- PRINT FUNCTION -->
<script type=“text/javascript”>
function PrintDiv() {
var contents = document.getElementById(“dvContents”).innerHTML;
var frame1 = document.createElement(‘iframe’);
frame1.name = “frame1”;
frame1.style.position = “absolute”;
frame1.style.top = “-1000000px”;
document.body.appendChild(frame1);
var frameDoc = frame1.contentWindow ? frame1.contentWindow : frame1.contentDocument.document ? frame1.contentDocument.document : frame1.contentDocument;
frameDoc.document.open();
frameDoc.document.write(’<html><head><title>{title}</title>’);
frameDoc.document.write(’</head><body>’);
frameDoc.document.write(contents);
frameDoc.document.write(’</body></html>’);
frameDoc.document.close();
setTimeout(function () {
window.frames[“frame1”].focus();
window.frames[“frame1”].print();
document.body.removeChild(frame1);
}, 500);
return false;
}
</script>
</head>
<body>
<!-- PRINT BUTTON -->
<input type=“button” onclick=“PrintDiv();” value=“Print” />