Code:
var grid = Ext.define('Writer.Grid', {
extend: 'Ext.grid.Panel',
alias: 'widget.writergrid',
requires: [
'Ext.grid.plugin.CellEditing',
'Ext.form.field.Text',
'Ext.toolbar.TextItem',
'Ext.ux.grid.Printer'
],
initComponent: function(){
this.editing = Ext.create('Ext.grid.plugin.RowEditing', {
clicksToMoveEditor: 1,
autoCancel: false
});
Ext.apply(this, {
title: 'Invoice summary' + ' [<?php echo $customer_information['id'] .' ' .$customer_information['name'] ?>]',
iconCls: 'icon-grid',
frame: true,
plugins: [this.editing],
columns: [{
text: '<?php echo __('Invoice number') ?>',
width: 80,
sortable: true,
dataIndex: 'number',
renderer: function(value, metaData, record, rowIndex, colIndex, store) {
var linkReturn = '';
var customerId = '<?php echo $customer_information['id'] ?>';
if (!isNaN(record.data.number) && record.data.number != '') {
linkReturn = '<a href="' + url + "/agent/invoicePaymentSummary/" + '<?php echo $customer_information['id'] ?>'+ "/" + record.data.number +'">'+ record.data.number +'</a>';
} else {
linkReturn = record.data.number;
}
return linkReturn;
}
}, {
header: '<?php echo __('Date') ?>',
width: 70,
sortable: true,
dataIndex: 'date',
renderer: Ext.util.Format.dateRenderer('d-m-Y'),
}, {
header: '<?php echo __('Due date') ?>',
width: 70,
sortable: true,
dataIndex: 'due_date',
renderer: Ext.util.Format.dateRenderer('d-m-Y'),
renderer: function(value, metaData, record, rowIndex, colIndex, store) {
var returnValue = Ext.Date.format(value, "d-m-Y");
var dueDate = value;
var today = new Date();
if(dueDate < today && record.data.overdue_days > 0) {
returnValue = '<p class="red">'+ returnValue +'</p>';
}
return returnValue;
}
}, {
header: '<?php echo __('Invoice amount') ?>',
width: 90,
sortable: true,
dataIndex: 'invoice_amount',
align: 'right',
renderer: money
}, {
header: '<?php echo __('Paid') ?>',
width: 90,
sortable: true,
dataIndex: 'paid',
align: 'right',
renderer: money
}, {
header: '<?php echo __('Remaining') ?>',
width: 90,
sortable: true,
dataIndex: 'remaining',
align: 'right',
renderer: money
}, {
header: '<?php echo __('Currency') ?>',
width: 60,
sortable: true,
dataIndex: 'currency'
}, {
header: '<?php echo __('Draft') ?>',
width: 40,
sortable: true,
dataIndex: 'draft',
align: 'right',
renderer: redClass
}, {
header: '<?php echo __('Overdue days') ?>',
width: 80,
sortable: true,
dataIndex:"overdue_days",
align: 'right',
renderer: redOverdueDaysClass
}, {
xtype: 'numbercolumn',
header: '<?php echo __('Pay-week') ?>',
width: 80,
sortable: true,
dataIndex:"pay_week",
format: '0',
field: {
xtype: 'numberfield',
allowBlank: false,
minValue: period,
regex: /^[0-9]{4}([0][1-9]|[1-4][0-9]|[5][0-2])$/i,
maskRe: /^[0-9]{4}([0][1-9]|[1-4][0-9]|[5][0-2])$/i,
regexText: 'Format YYYYWW (Min. YYYY01 - Max. YYYY52)'
},
align: 'right',
vtype: 'payweek',
renderer: redPayWeekField
}, {
header: '<?php echo __('Comment') ?>',
width: 220,
sortable: true,
dataIndex:"comment",
field: {
type: 'textfield',
maxLength: 30,
emptyText: ''
},
renderer: redCommentField
}, {
header: '<?php echo __('Send address') ?>',
width: 200,
sortable: true,
dataIndex:"send_address"
}, {
header: '<?php echo __('PDF') ?>',
width: 40,
sortable: true,
dataIndex:"pdf",
renderer: function(value, metaData, record, rowIndex, colIndex, store) {
var pdfReturn = '';
var customerId = '<?php echo $customer_information['id'] ?>';
if (!isNaN(record.data.number) && record.data.number != '')
pdfReturn = '<a href="' + url + '/agent/invoiceSummary/viewInvoice/'+ record.data.number +'/'+ customerId +'" target="_blank">'+ '<img src="/images/icons/pdf_icon.gif"></a>';
return pdfReturn;
}
}],
tbar: [{
text: 'Print',
iconCls: 'icon-print',
handler : function(){
Ext.ux.grid.Printer.printAutomatically = true;
Ext.ux.grid.Printer.print(Ext.ComponentQuery.query('writergrid[itemId=grid]')[1]);
}
}]
});
this.callParent();
onSync: function(){
this.store.sync();
}
});
Now I'd like to print the first grid and print the second grid with both their own print button in the toolbar.