MINOR SSF-297 add more available information to GridField print view

This commit is contained in:
Normann Lou 2012-04-04 14:06:47 +12:00
parent 7f8a682ad7
commit 721184c4b3
2 changed files with 21 additions and 0 deletions

View File

@ -131,10 +131,24 @@ class GridFieldPrintButton implements GridField_HTMLProvider, GridField_ActionPr
)); ));
$item->destroy(); $item->destroy();
} }
//get title for the print view
$form = $gridField->getForm();
$currentController = Controller::curr();
$title = method_exists($currentController, 'Title')?$currentController->Title():
($currentController->Title?$currentController->Title:
($form?$form->Name():''));
if($fieldTitle = $gridField->Title()) $title .= ($title?' - ':'').$fieldTitle;
//$state = $gridField->getState(false)->__toString();
$ret = new ArrayData( $ret = new ArrayData(
array( array(
"Title" => $title,
"Header" => $header, "Header" => $header,
"ItemRows" => $itemRows, "ItemRows" => $itemRows,
"Datetime" => SS_Datetime::now(),
"Member" => Member::currentUser(),
) )
); );

View File

@ -1,8 +1,10 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//MI" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//MI" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="mi" lang="mi"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="mi" lang="mi">
<head> <head>
</head> </head>
<body> <body>
<% if $Title %><h3>$Title</h3><% end_if %>
<table> <table>
<thead> <thead>
<tr><% control Header %><td>$CellString</td><% end_control %></tr> <tr><% control Header %><td>$CellString</td><% end_control %></tr>
@ -13,5 +15,10 @@
<% end_control %> <% end_control %>
</tbody> </tbody>
</table> </table>
<p>
Printed at $Datetime.Nice
<br />
Printed by $Member.Name
</p>
</body> </body>
</html> </html>