Establezca el texto de la insignia después de cargar la tienda con Sencha Touch

I can get the count of items after loading a store and I want to know how and where to update the badge text for the button in the tabbar in the current view.

Here I have my view panel and I think that I could set the badge text in the initialize function: Ext.define('connect.view.InProgressPanel', { extend: 'Ext.NavigationView', xtype: 'inprogressPanel', requires: [ 'connect.view.inprogressleads.InProgressList' ], config: { itemId: 'inprogressPanel', title: 'Leads In Process', iconCls: 'team', items:[{ title: 'Leads In Process', xtype: 'inprogressList' }] }, initialize: function( eOpts ) {
var store = Ext.getStore('InProgressLeads'); store.on('load', function () { var listCount = store.getCount(); console.log(listCount); // set the badge here }); } });

And here I define the button for the panel in the main view: { id: 'lipPanel', title: 'Leads In Process', iconCls: 'team',
items: [{ xtype: 'inprogressPanel' }] },

I have read that I could give a button an ID and then I could use the ID to get the reference to the button, yet I've not found any way to specify the ID of a button when I define it this way in the main panel. Or is there another way to get the button and set the badge text?

Update: Here is a way to set the badge:

<code>
      store.on('load', function () {

        var listCount = store.getCount(); 
        var apptabbar = Ext.getCmp('ext-tabbar-1');
        var tab = apptabbar.down('.tab[title=Leads In Process]');
        tab.setBadgeText(listCount);            

      });
</code> 

preguntado el 28 de mayo de 14 a las 13:05

2 Respuestas

Prueba esto:

Ext.getCmp('lipPanel').setBadgeText(listCount);

contestado el 29 de mayo de 14 a las 13:05

No, this is not working: Uncaught TypeError: undefined is not a function - AlanP

Sorry.. i haven't seen your whole code...may be there is a problem in your code...as per you are saying that { id: 'lipPanel', title: 'Leads In Process', iconCls: 'team', items: [{ xtype: 'inprogressPanel' }] }, has a button. Then you need to post here your button's id... b'coz in my code there's id of a panel, which won't work.Just try to replace 'lipPanel' with your button's id and make sure at the time of initialize event, your view which is containing a button must be created and active. - Naitik

Natik, all there is for defining the button has been posted. It is mainly defined in the snippet from the main view. And there is some redundant code in inprogressPanel. I've commented out title and iconCls: 'team' in the inprogressPanel. So them how would I go about defining button with an id? - AlanP

See.. You want badge text on button, So you have to define a button somewhere in your panel like {xtype: 'button', id: 'badgeBtn', itemId: 'badgeBtn'}. right? So you just have to put that button's id on which you want badge text. Simple! - Naitik

I have tried defining the button in either the InProgressPanel, in the config, or in the main view. In either instance the button replaces the list in the panel's view. It seems that somehow the button to replace the toolbar button should be defined in the main view where lipPanel is defined, but probably not as within it list of items. Do you have an example of one that works? Thanks. - AlanP

Get a reference to the tabbar and then get a reference to the button by its name. var apptabbar = Ext.getCmp('ext-tabbar-1'); var tab = apptabbar.down('.tab[title=Leads In Process]'); tab.setBadgeText(listCount);

Respondido el 02 de junio de 14 a las 16:06

that's what Naitik's answer was about, he described that you should use you button's id, should have accepted it, instead basing on it a different answer. - ezzarghili

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.