-
16 Nov 2011 5:41 AM #1
Answered: Cannot setBadgeText on Tab within Tab.Panel
Answered: Cannot setBadgeText on Tab within Tab.Panel
In ST1, I could set the badge text to, say 50, with the following:
Ext.getCmp("MessagesInbox").tab.setBadge(50)
I might be missing something in ST2, but it doesn't seem possible?
I've tried setBadgeText which can be used on buttons etc, but no joy.
Any help gratefully accepted!
Thanks,
DW
-
Best Answer Posted by AndreaCammarata
Hi.
You should first get the tabBar component and then set the badge text on the wanted tab button.
Here's an example:
Hope this helps.Code:Ext.setup({ onReady: function() { var setBadge = function(){ tabPanel.getTabBar().getComponent(0).setBadge('Hello'); }; var tabPanel = Ext.create('Ext.tab.Panel', { fullscreen: true, type: 'dark', sortable: true, tabBar: { docked: 'bottom', layout: { pack: 'center' } }, items: [ { xtype: 'toolbar', docked: 'top', items: [ { xtype: 'button', text: 'Set Badge', handler: setBadge } ] }, { title: 'Tab 1', html: '1', cls: 'card1', iconCls: 'bookmarks' }, { title: 'Tab 2', html: '2', cls: 'card2', iconCls: 'download' }, { title: 'Tab 3', html: '3', cls: 'card3', iconCls: 'favorites' } ] }); } });
-
16 Nov 2011 9:03 AM #2
Hi.
You should first get the tabBar component and then set the badge text on the wanted tab button.
Here's an example:
Hope this helps.Code:Ext.setup({ onReady: function() { var setBadge = function(){ tabPanel.getTabBar().getComponent(0).setBadge('Hello'); }; var tabPanel = Ext.create('Ext.tab.Panel', { fullscreen: true, type: 'dark', sortable: true, tabBar: { docked: 'bottom', layout: { pack: 'center' } }, items: [ { xtype: 'toolbar', docked: 'top', items: [ { xtype: 'button', text: 'Set Badge', handler: setBadge } ] }, { title: 'Tab 1', html: '1', cls: 'card1', iconCls: 'bookmarks' }, { title: 'Tab 2', html: '2', cls: 'card2', iconCls: 'download' }, { title: 'Tab 3', html: '3', cls: 'card3', iconCls: 'favorites' } ] }); } });Sencha Inc
Andrea Cammarata, Solutions Engineer
CEO at SIMACS
@AndreaCammarata
www.andreacammarata.com
github: https://github.com/AndreaCammarata
-
16 Nov 2011 2:19 PM #3
Spot On.
Thank you so much for such a prompt reply.
DW
-
9 Feb 2012 7:58 AM #4
In Beta 1 there seems to be a styling bug:
I'm using the procedure above, and the badgeText is not position on the button, but on the toolbar itself.
Capture.PNG
Layout:
NavPanel
- TabPar
- - Item With Form
- - Item with List
- - Item with List
- - Item with Map
No custom styling, generated by designer 2 beta -build 276
The badgeText is expected to be on button 2.
I'm setting the badge in ha store load event, code snipped is from controller init.
Code:Ext.getStore('Oppgaver').on('refresh',function(store) { this.getTabPanel().getTabBar().getComponent(1).setBadgeText(store.getCount()); }, this);Sven Tore Iversen
-
9 Feb 2012 8:18 AM #5
Woop- woop there's a beta 2
but the problem remains
Sven Tore Iversen
-
7 May 2012 10:01 PM #6
Hai I Use the following way Its wrk fine:
Hai I Use the following way Its wrk fine:
First get tab component from the view.
Ext.getCmp('Invites').getTabBar().getComponent(0);
console.log(Ext.getCmp('Invites').getTabBar().getComponent(0)._badgeText);
Ext.getCmp('Invites').getTabBar().getComponent(0).setBadgeText('5');
console.log(Ext.getCmp('Invites').getTabBar().getComponent(0)._badgeText);


Reply With Quote