2013-02-25 150 views
1

Complete Code is hereSencha Touch:隱藏嵌套列表中的工具欄按鈕?

我有以下煎茶應用嵌套列表,其包括工具欄按鈕的。

enter image description here

每當我點擊任何列表項目,我需要刪除它說「標籤欄」在下面的列表中的按鈕。正如你所看到的,該按鈕仍然存在,我需要刪除。

enter image description here

繼承人我的視圖代碼

煎茶查看文件夾

Main.js

Ext.define('firstApp.view.Main', { 
extend : 'Ext.Container', 
xtype : 'main', 
requires: [ 
       'Ext.TitleBar', 
       'Ext.Button', 
       'firstApp.model.item', 
       'firstApp.store.nList', 
       'Ext.dataview.NestedList', 
       'Ext.data.TreeStore' 
       //'Ext.ToolBar' 
       ] , 
config : { 
    fullscreen : true, 
    layout : 'fit', 
    items : [{ 
     xtype : 'nestedlist', 
     title: 'List View', 
     displayField : 'text', 
     store : 'nList', 
     //toolbar:{ 
     toolbar:{ 
      items :[ 
          { 
           xtype : 'spacer' 
           }, 
          { 
           xtype : "button", 
           text : 'Tab View', 
           align: 'right', 
           ui : "action", 
           handler: function(){      
              Ext.Viewport.animateActiveItem((
              Ext.create('firstApp.view.view2')), 
              {type: 'slide', direction:'left'}).show(); 
                } 
          } 
         ] 
        } 
       } 
      ] 
    } 
}); 

我應該如何去做?請幫我出

+0

是它選項卡視圖還是選項卡欄? – 2013-02-25 08:42:02

+0

@SudipPal按鈕的名稱是標籤視圖...我已附加快照以及...我需要做的是隱藏這個按鈕,當我在我的嵌套列表的子菜單中。我相信你可以通過查看問題和快照來確定我想要問的問題。 – madLokesh 2013-02-25 08:47:58

+0

是否有任何其他視圖可用於您的子菜單列表項目?像viewport或view2 ..好心地粘貼該代碼以及... – 2013-02-25 08:52:23

回答

7

http://www.senchafiddle.com/#33NZD

在這裏你去好朋友..

我做什麼

  1. 分配一個ID給你 「標籤,查看按鈕」
  2. 新增2個監聽器你嵌套列表
  3. itemtap將通過id獲得按鈕,並將隱藏它和
  4. 後面會通過ID拿到按鈕,將顯示它

這裏是代碼

都給ID來按鈕

xtype : "button", 
         id: "btnTabView", 
         text : 'Tab View', 
         align: 'right', 
         ui : "action", 
         handler: function(){      
          Ext.Viewport.animateActiveItem((
           Ext.create('firstApp.view.view2')), 
                  {type: 'slide', direction:'left'}).show(); 
         } 

聽衆給你嵌套列表

displayField : 'text', 
store : 'nList', 
listeners: { 
    back: function(nList, node, lastActiveList, detailCardActive, eOpts){ 
     if(node.getDepth() == 1){ 
      Ext.getCmp('btnTabView').show(); 
     } 
    }, 
    itemtap: function(nList, list, index, target, record, e, eOpts){ 
      Ext.getCmp('btnTabView').hide(); 
    } 
}, 
+0

真棒回答'+1',但有一個小故障,當你添加回監聽器時,每當我從我的嵌套列表中的第n列表到第(n-1)列表時,它將被調用。因此,向前推進,這個代碼完美的工作,但回去時,它不會是一樣的。 @SirwaniMayur。有什麼想法嗎 ? – madLokesh 2013-02-26 06:40:37

+0

@innocentDemon請找到我更新的答案。這將解決您的問題。如果答案是您所期望的,請將其標記爲正確答案 – 1Mayur 2013-02-26 07:14:59

+0

完美。作爲初學者,我對聽衆和嵌套列表節點概念有了一些見解 – madLokesh 2013-02-26 07:18:53