PDA

View Full Version : How to configure a grid toolbar from a container create config



CE_REAL
25 Oct 2012, 1:05 AM
I'd like to configure my toolbar which I have defined in a grid define:



var grid = Ext.define('Writer.Grid', {
extend: 'Ext.grid.Panel',
alias: 'widget.writergrid',


initComponent: function() {


Ext.apply(this, {
...
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]);
}
}]
});
}
}


from the container create config when creating the container which holds the grid:



var main = Ext.create('Ext.container.Container', {
renderTo: Ext.Element.get('invoice-summary'),
layout: 'fit',
height: 400,
autoHeight: true,
items: [{
itemId: 'grid',
xtype: 'writergrid',
flex: 1,
store: store
}]
});

vietits
25 Oct 2012, 2:15 AM
Try to fix your code as below:


var grid = Ext.define('Writer.Grid', {
extend: 'Ext.grid.Panel',
alias: 'widget.writergrid',


initComponent: function() {


Ext.apply(this, {
...
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(arguments);
}
}