Permalink
Browse files

ENHANCEMENT: SSF-168 refactoring print button so that it opens print …

…view in a new window. This is useful for debugging and also useful for when someone wants to use the print view not for printing, but for viewing a clean version of a gridfield without the surrounding CMS, using the view for copying and pasting into another app, for example.
  • Loading branch information...
Julian Seidenberg
Julian Seidenberg committed Apr 5, 2012
1 parent 206c61f commit 14c3fd75a103dcc51c6d16c4522f22b0542de646
Showing with 6 additions and 12 deletions.
  1. +3 −10 javascript/GridField.js
  2. +3 −2 templates/Includes/GridField_print.ss
View
@@ -119,15 +119,7 @@
this.setUUID(new Date().getTime());
},
onclick: function(e){
- var self = this, iframeID = 'gridfield-print-iframe' + this.getUUID();
- var printIframe = $('#' + iframeID);
-
- if(!printIframe.length){
- printIframe = $('<IFRAME id="'+iframeID+'" class="ss-gridfield-print-iframe">');
- $(document.body).append(printIframe);
- }
-
- var self = this, btn = this.closest(':button'), grid = this.getGridField(),
+ var btn = this.closest(':button'), grid = this.getGridField(),
form = this.closest('form'), data = form.find(':input').serialize();
// Add current button
@@ -138,7 +130,8 @@
if(window.location.search) data = window.location.search.replace(/^\?/, '') + '&' + data;
var url = $.path.makeUrlAbsolute(grid.data('url') + '?' + data, $('base').attr('href'));
- printIframe.attr('src', url);
+ var newWindow = window.open(url);
+
return false;
}
});
@@ -1,9 +1,9 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
-
+ <% if $Title %><title>$Title</title><% end_if %>
</head>
- <body>
+ <body onload="window.print();">
<% if $Title %><h3>$Title</h3><% end_if %>
<table>
<thead>
@@ -21,4 +21,5 @@
<% _t('GridField.PRINTEDBY', 'Printed by') %> $Member.Name
</p>
</body>
+
</html>

0 comments on commit 14c3fd7

Please sign in to comment.