2015-05-01 37 views
0

我有一個配置文件主頁視圖(Home2)。在這個視圖中,想要顯示頂部停靠的標題欄,用戶配置文件信息和用戶帖子。ExtJs DataView vbox中的高度

Ext.define('FreescribbleApp.view.Home2', { 
extend: 'Ext.Panel', 
xtype: 'homepage2', 
config: { 

    title: 'Home', 
    iconCls: 'home', 

    styleHtmlContent: true, 
    scrollable: true, 
    items:[ 
     { 
      xtype: 'titlebarview' 
     }, 
     { 
      xtype: 'userinfoview', 
      itemId: 'userInfoWrapper', 
      height: 150 
     }, 
     { 
      itemId: 'homeStage', 
      autoScroll: true 
     } 
    ] 
} 
}); 

我也有一個數據視圖:

Ext.define('FreescribbleApp.view.PostList', { 
extend: 'Ext.dataview.DataView', 
xtype: 'postlist', 
config: { 
    scrollable: false, 
    defaultType: 'postitem', 
    useComponents: true 
} 
}); 

列出DataItems:

Ext.define('FreescribbleApp.view.PostItem', { 
extend: 'Ext.dataview.component.DataItem', 
xtype: 'postitem', 
requires: ['Ext.field.Text'], 
config: { 
    style: 'background-color: #f00', 
    height: 100, 
    styleHtmlContent: false, 
    authorName: { 
     height: 30, 
     style: 'background-color: #0f0' 
    }, 
    dataMap: { 
     getAuthorName: { 
      setHtml: 'userName' 
     } 
    }, 
}, 
applyAuthorName: function(config) { 
    return Ext.factory(config, Ext.Component, this.getAuthorName()); 
}, 
updateAuthorName: function(newAuthorName, oldAuthorName) { 

    if (newAuthorName) { 
     this.add(newAuthorName); 
    } 
    if (oldAuthorName) { 
     this.remove(oldAuthorName); 
    } 
} 
}); 
在我的HomeController

我創建了一個PostStore,一些職位填滿它,並添加到數據視圖。之後,我將DataView添加到Home2-View Element HomeStage:

var postStore = Ext.create('FreescribbleApp.store.PostStore', { 
     params: { 
      user: localStorage.getItem('userId'), 
      token: localStorage.getItem('token'), 
      target: localStorage.getItem('userName') 
     } 
    }); 

    postStore.load(); 
    postStore.on('load', function(){ 
     var currentView = Ext.create('FreescribbleApp.view.PostList'); 
     currentView.setStore(postStore); 
     homeStage.add(currentView); 
    }); 

直到我設置了DataView的高度後才能看到任何項目。這是一個常見問題,在我的情況下發髻我不能設置我的HomeStage'適合',因爲它只是Home2的一部分,並且項目userinfo應該與帖子滾動。那麼我怎樣才能動態地設置我的DataView的大小呢?

我也在我的Sencha debuger中看到Chrome在我的DataView-List和我的DataItems之間是一個容器,裏面有所有物品的權利高度。我可以只獲取這個容器的大小併爲我的DataView設置我的大小嗎?它會起作用嗎?它會是一個好的做法嗎?

回答

0

對不起,我只是在我的DataView中設置了滾動:null,而不是false!