Wednesday, 15 May 2013

extjs - How to update badgeText in Sencha Touch (Ext.Container) -



extjs - How to update badgeText in Sencha Touch (Ext.Container) -

currently i'm newbie in sencha , want update badgetext in sencha touch store count in ext.container, please see code below reference give thanks , god bless.

ext.define('xx.view.menu',{ extend: 'ext.container', xtype: 'menu', config: { cls: 'mainmenu', docked: 'left', top: 0, left: 0, bottom: 0, zindex: 0, width: 266, padding: '0 0 0 0', open: false, scrollable: 'vertical', defaulttype: 'button', defaults: { textalign: 'left' }, scrollable: { indicators: false }, items: [{ text: 'home', ui: 'mainmenu', iconcls: 'home', itemid: 'home' },{ text: 'contact us', ui: 'mainmenu', iconcls: 'form', itemid: 'contactus' },{ text : 'notifications', ui: 'mainmenu', badgetext: '0', iconcls: 'form', itemid: 'notifications' }] }, setparent: function(parent) { this.callparent(arguments); this.maskcmp = parent.add({ xtype : 'component', cls : 'mainmenu-mask', top : 0, zindex : 5000, hidden : true, width : 9999, left : this.getwidth(), bottom : 0 }); this.maskcmp.element.on({ scope : this, touchend: 'onmaskrelease' }); } });

edit: 1 working per sujata's - tap event

config: { refs: { notificationsmenuitem: 'menu #notifications' }, control: { notificationsmenuitem: { tap: 'notificationsitemtap' } } } notificationsitemtap: function(button){ button.setbadgetext('1'); }

edit: update-02 - working modified code per sujata's latest reply:

config: { refs: { notificationsmenuitem: 'menu #notifications' } }, control: { main: { initialize: 'maininitialize', navigationmode: 'switchtonavigation' } }, maininitialize: function() { this.getnotificationsmenuitem().setbadgetext('48'); }

you can set setbadgetext method. add together 'name: "notifications"' field in button view. in controller refs of button this:

refs: { notificationsbtn : 'button[name="notifications"]' }

get button tap event :

control: { notificationsbtn : { tap : function(btn) { btn.setbadgetext('1'); // store info , set } }

edit:-

to badge text on menu load can utilize initialize method of view, this:-

refs: { menu: 'menu', notificationsbtn : 'button[name="notifications"]' }, control: { menu : { initialize : function(){ this.getnotificationsbtn().setbadgetext('1'); } } }

extjs sencha-touch sencha-touch-2 sencha-touch-2.1

No comments:

Post a Comment