PDA

View Full Version : [ASK] getTopToolBar Undifined



endimion
9 Apr 2012, 6:36 AM
Helo,,,,
Iam Using ExtJs 3.2.1
And i would add Export Excel button to toolbar...
But any error with this Info :


Uncaught TypeError: Object function (){G.apply(this,arguments)} has no method 'getTopToolbar'

and this my code :


var ExcelSiswa = new Ext.ux.Exporter.Button({ id: 'excel-siswa',
component: Ext.data.GridSiswa,
text : "Export Ke Excel"
});
Ext.data.GridSiswa.getTopToolbar().add(ExcelSiswa);

Thanks... :):):)

scottmartin
9 Apr 2012, 8:21 AM
You need to get the instance:

Ext.getCmp("excel-siswa").getTopToolbar().addButton({text: 'Excel Button'})

Regards,
Scott.

endimion
9 Apr 2012, 1:06 PM
Still Error sir,,,
This Is My Grid :

Ext.data.GridSiswa = Ext.extend(Ext.grid.EditorGridPanel ,{ //height : 438,
store: Ext.grid.DataSiswa,
cm: Ext.data.columnDataSiswa,
autoScroll: true,
style: {padding: 5},
id: 'gridsiswa',
trackMouseOver: true,
selModel: new Ext.grid.RowSelectionModel({singleSelect:true}),
tbar: [
{
text: 'Hapus Siswa',
iconCls:'delete'
,handler: function(){Ext.deleteSiswa();}


}, '-',
{
text: 'Full Data',
iconCls:'cari'

}, '->',
{
xtype : 'combo',
width : 100,
id : 'cmbCari',
store : [
'Nis',
'Nama',
'Kelas',
'Alamat'
],
//allowBlank: false,
typeAhead: true,
triggerAction: 'all',
mode: 'local',
forceSelection: true,
displayField: 'type',
valueField: 'id',
lazyRender:true
}, '-',
{
xtype: 'textfield'
,id : 'txtCari'
,width : 100

}, '-',
{
text: 'Cari',
iconCls:'cari'



}, '-'

],
bbar: new Ext.PagingToolbar({
pageSize: 20,
store: Ext.grid.DataSiswa,
displayInfo: true
})
,listeners: {click: function(){Ext.BinInfo();}
,'rowcontextmenu' : function(grid, index, event) {
showMenu(grid, index, event);
}
}

//selModel: Ext.extend(Ext.grid.RowSelectionModel, {singleSelect:true})

}


); // eo extend


Ext.reg('gridsiswa', Ext.data.GridSiswa);

please help me,,,

scottmartin
9 Apr 2012, 2:14 PM
My mistake, reading to fast .. you need the ID of your grid: id: 'gridsiswa',

Ext.getCmp("gridsiswa").getTopToolbar().addButton({text: 'Excel Button'})

Regards,
Scott.

endimion
10 Apr 2012, 5:47 AM
Ok,,, Thanks U very Much Sir,,,
Its Working,,, :):):)