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.

This commit is contained in:
Julian Seidenberg 2012-04-05 18:15:44 +12:00
parent 206c61fcd5
commit 14c3fd75a1
2 changed files with 6 additions and 12 deletions

View File

@ -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;
}
});

View File

@ -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>