2014-11-14 3 views
0

현재 Sencha의 초보자이고 매장에서 Sencha Touch의 badgeText를 업데이트하려고합니다. Ext.Container, 아래 코드를 참조하십시오. 참조 감사합니다. 신의 축복.Sencha Touch (Ext.Container)에서 badgeText를 업데이트하는 방법

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' 
     }); 

    } 




}); 

편집 :이 사람이 한 Sujata의에 따라 작동하고 - 탭 이벤트

 config: { 
    refs: { 
     notificationsMenuItem: 'menu #notifications' 
    }, 
    control: { 

     notificationsMenuItem: { 
      tap: 'notificationsItemTap' 
     } 
    } 
} 

notificationsItemTap: function(button){ 
    button.setBadgeText('1'); 
} 

편집 : UPDATE - 02 - 한 Sujata의 최신 회신에 따라 코드 수정 작업 :

config: { 
    refs: { 
     notificationsMenuItem: 'menu #notifications' 
    } 
}, 
    control: { 
     main: { 
      initialize: 'mainInitialize', 
      navigationMode: 'switchToNavigation' 
     } 
    }, 
    mainInitialize: function() { 
    this.getNotificationsMenuItem().setBadgeText('48'); 
} 

답변

0

당신 setBadgeText 방법으로 설정할 수 있습니다. 버튼보기에 'name : "알림"필드를 추가하십시오. 컨트롤러에서 다음과 같이 버튼의 심판을받을 :

control: { 
    notificationsBtn : { 
     tap : function(btn) { 
      btn.setBadgeText('1'); // Get your store data and set 
     } 
} 

편집 :

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

버튼 탭 이벤트 가져 오기 -

메뉴 부하 당신의 배지 텍스트를 얻으려면을 다음과 같이 뷰의 초기화 메소드를 사용할 수 있습니다. -

refs: { 
     menu: 'menu', 
     notificationsBtn : 'button[name="notifications"]' 
    }, 
    control: { 
     menu : { 
     initialize : function(){ 
      this.getNotificationsBtn().setBadgeText('1'); 
     } 
    } 
    } 
+0

안녕하세요, @Sujata, 고마워요. 귀하의 회신에 대단히. 현재이 'XX.view.Menu'에는 컨트롤러가 없으므로 badgeText를 나타내는 다른 컨트롤러에 심판을 추가하게되면 형식이 어떻게됩니까? –

+0

미안하지만 당신이 원하는 것을 이해할 수 없습니다. 너는 그것을 깨끗이 할 수 있니? 'setParent' 메소드에서 badgeText를 설정해야합니까? –

+0

안녕하세요 @Sujata 나는 이미 위의 코드를 편집했습니다. 희망을 분명히 설명했으면 좋겠다. 도와 주셔서 대단히 감사합니다! –