2012-07-12 82 views
5

我試圖用容器上的列表編寫簡單的視圖,但是我有一些問題。所有的 首先,列表是,當我試圖做這樣的不可見:Sencha Touch 2列表在容器中是不可見的

Ext.define('App.view.News', { 
    extend: 'Ext.Container', 

,但是當它是這樣寫的:

Ext.define('App.view.News', { 
    extend: 'Ext.navigation.View', 

它的工作原理。

問題是,當我用navigation.View擴展編寫它時,我得到兩個工具欄在頂部,我找不到解決方案禁用第二個(由列表添加)。

全碼:

Ext.define('App.view.News', { 
    extend: 'Ext.Container', //Ext.navigation.View 
    xtype: 'news', 
    requires: [ 
     'Ext.dataview.List', 
     'Ext.data.proxy.JsonP', 
     'Ext.data.Store' 
    ], 
    config: { 
     style: ' background-color:white;', 

     items: 
     [ 
      { 
       xtype: 'toolbar', 
       docked: 'top', 
       title: 'News', 
       minHeight: '60px', 
       items: [ 
        { 
         ui: 'back', 
         xtype: 'button', 
         id: 'backButton', 
         text: 'Back', 
        }, 

        { 
         minHeight: '60px', 
         right: '5px', 
         html: ['<img src="resources/images/Image.png"/ style="height: 100%; ">',].join(""), 
        }, 
       ],   
      }, 

      { 
       xtype: 'list', 
       itemTpl: '{title},{author}', 
       store: { 
        autoLoad: true, 
        fields : ['title', 'author'], 
        proxy: { 
         type: 'jsonp', 
         url: 'https://ajax.googleapis.com/ajax/services/feed/load?v=1.0&q=http://feeds.feedburner.com/SenchaBlog', 
         reader: { 
          type: 'json', 
          rootProperty: 'responseData.feed.entries' 
         } 
        } 
       } 
      } 
     ] 
    } 
}); 

請幫助!

回答

10

你需要給你的容器佈局,你的列表是一個flex屬性。 flex在列表中很重要,因爲它們在滾動時沒有可視高度。我在下面的代碼中添加了一些屬性。希望這可以幫助。

Ext.define('App.view.News', { 
    extend: 'Ext.Container', //Ext.navigation.View 
    xtype: 'news', 
    requires: [ 
     'Ext.dataview.List', 
     'Ext.data.proxy.JsonP', 
     'Ext.data.Store' 
    ], 
    config: { 
     style: ' background-color:white;', 
     layout: 'vbox', // add a layout 
     items: 
     [ 
      { 
       xtype: 'toolbar', 
       docked: 'top', 
       title: 'News', 
       minHeight: '60px', 
       items: [ 
        { 
         ui: 'back', 
         xtype: 'button', 
         id: 'backButton', 
         text: 'Back', 
        }, 

        { 
         minHeight: '60px', 
         right: '5px', 
         html: ['<img src="resources/images/Image.png"/ style="height: 100%; ">',].join(""), 
        }, 
       ],   
      }, 

      { 
       xtype: 'list', 
       itemTpl: '{title},{author}', 
       flex: 1, // add a flex property 
       store: { 
        autoLoad: true, 
        fields : ['title', 'author'], 
        proxy: { 
         type: 'jsonp', 
         url: 'https://ajax.googleapis.com/ajax/services/feed/load?v=1.0&q=http://feeds.feedburner.com/SenchaBlog', 
         reader: { 
          type: 'json', 
          rootProperty: 'responseData.feed.entries' 
         } 
        } 
       } 
      } 
     ] 
    } 
}); 
+0

這就是我想要的。非常感謝! – kmb 2012-07-13 07:28:30

+0

哦,你救了我的命!該死的彎曲......在這個愚蠢的名單後我開始生氣了! :P – Olivier 2013-01-23 14:57:59

+0

剛剛減輕了3小時。我必須將容器佈局設置爲'合適'。謝謝! – Lucian 2013-06-13 15:19:01