PDA

View Full Version : Toolbars of panels are inacessible



pvleeuwen
28 Aug 2020, 2:46 PM
Fellow programmers,

I have the following problem. I am adding tbars to panels in an application. Those tbars must contain datefields. If the 'genera' period selector is used, I must write the selected dates in those datefields. But it is impossible to access the tbars from outside. The method panel.getTbar() doesn't seem to exist and the tbars of panels are actually shown as null.

For example:


new Ext.Panel({

width: '100%',
title: 'BOVEN',
layout: {
type: 'hbox',
},
defaults: {
flex: 1,
height: '100%'
},
items: [
{
xtype: 'kpi.scoresByMonth',
id: 'ccKpiScoresByMonth',
tbar: [
{ text: 'BUTTON'}
]
},
{
xtype: 'kpi.contractRevenuesByMonth',
id: 'ccKpiContractRevenuesByMonth'
}
],
style: {
'border': '4px solid red'
}
})

I can look up the component - ccKpiScoresByMonth - by its id, and it is found. The debugger shows it with properties and the right id. But the tbar is null and getTbar() doesn't work at all. I have been stuck at this for hours! Does anybody have any clue where this can possible come from?

Thanks in advance for any help!

pvleeuwen
29 Aug 2020, 2:41 PM
I have found the problem. I was using documentation of 'modern' but the app is in 'classic', so it doesn't support the getTbar method. Strangely enough the tbar may or not be accessible from the outside depending on how the object has been created. If I create it with only the xtype I can access the toolbar, but getComponent() doesn't work. If I create it with Ext.Create(...) it is the other way round: no tbar but getComponent works.

I currently access the components in the toolbar using their reference and the lookup method. That works and seems to be the intended way of doing it.

jvandemerwe
8 Sep 2020, 5:02 AM
Why not using 'dockedItems'?



dockedItems: [{
xtype: 'SomeToolbar',
dock: 'top'
},{
xtype: 'SomeOtherToolbar',
dock: 'top',
}, {
xtype: 'pagingtoolbar',
store: store,
dock: 'bottom'
}],


I have found the problem. I was using documentation of 'modern' but the app is in 'classic', so it doesn't support the getTbar method. Strangely enough the tbar may or not be accessible from the outside depending on how the object has been created. If I create it with only the xtype I can access the toolbar, but getComponent() doesn't work. If I create it with Ext.Create(...) it is the other way round: no tbar but getComponent works.

I currently access the components in the toolbar using their reference and the lookup method. That works and seems to be the intended way of doing it.