2011-07-11 74 views
0

我需要一點幫助,我在Sencha Touch中構建應用程序,並且我需要在按下按鈕時更改容器內的停靠項目。我認爲這是改變應用程序內容的最佳方式(即在頁面之間切換)。在Sencha Touch中使用按鈕處理程序添加面板

到目前爲止,我有以下的代碼 -

var App = new Ext.Application({ 
    name: 'Test', 
    useLoadMask: true, 
    launch: function() { 

     // Toolbar 
     Test.views.toolbar = new Ext.Toolbar({ 
      id: 'toolbar', 
      title: 'Friend Pay' 
     }); 

     // Content 
     Test.views.content = new Ext.Panel({ 
      id: 'content', 
      layout: 'fit', 
      dockedItems: [{ 
       cls: 'copy', 
       html: '<h2>Copy block</h2>' 
      }, { 
       xtype: 'button', 
       id: 'buttonPanel', 
       html: 'Request Payment', 
       handler: function() { 
        // Link to newBlock panel 
       } 
      }] 
     }); 

     // Content 
     Test.views.newBlock = new Ext.Panel({ 
      id: 'content', 
      layout: 'fit', 
      dockedItems: [{ 
       cls: 'copy', 
       html: '<h2>Test 2</h2>' 
      }] 
     }); 

     // Container 
     Test.views.container = new Ext.Panel({ 
      id: 'container', 
      layout: 'fit', 
      dockedItems: [Test.views.toolbar, Test.views.content] 
     }); 

     // Viewport - Entire screen 
     Test.views.viewport = new Ext.Panel({ 
      fullscreen: true, 
      scroll: 'vertical', 
      items: [Test.views.container] 
     }); 

    } 
}); 

的按鈕處理程序()的函數標籤內,需要什麼功能改變容器內的dockedItem是newBlock,而不是內容。

非常感謝您的幫助。

回答

0

addDockedremoveDocked

Test.views.viewport.removeDocked(Test.views.content) 
Test.views.viewport.addDocked(Test.views.newBlock) 

這似乎有點奇怪你雖然添加內容到dockedItems,也許你換貨將它們添加到正常items收藏? 無論哪種方式,請檢查main api docsExt.Panel的所有可用內容,以熟悉標準組件功能。

相關問題