0
我在我的應用程序和「我的評論」選項卡中有一個選項卡面板,應該有一個用戶提交的評論部分,另一個用戶評論只有「喜歡」。目前,我正在使用JSON填充單個數據視圖,其中包含用戶與之交互的所有評論,並且用戶提交的評論與用戶「喜歡的」評論之間沒有分離。我想分開這兩個,並給每個標題。Sencha Touch 2:我如何將DataView分成不同頭部的兩部分?
我的標籤是這樣的:
{
title: 'Reviews Dashboard',
iconCls: 'action',
layout: 'fit',
xtype: 'reviewsdashboard'
items: [
{
docked: 'top',
xtype: 'titlebar',
title: 'Reviews Dashboard'
}
]
}
和我的「點評儀表盤」數據視圖看起來是這樣的:
var tpl = new Ext.XTemplate(
'<div class=dashbox>',
'<div class="col1">${starRating} for {movietitle}</div>',
'<div class="col2">Submitted by {user}</div>',
'<div class="col3">{status}</div>',
'</div>'
);
Ext.define('MyApp.view.ReviewsDashboard',
{
extend: 'Ext.dataview.DataView',
xtype: 'reviewsdashboard',
config:
{
xtype: 'dataview',
title: 'Reviews Dashboard',
itemTpl: tpl,
store:
{
autoLoad: true,
fields: [
{
name: 'id',
type: 'int'
},
{
name: 'user',
type: 'int'
},
{
name: 'movietitle',
type: 'string'
},
{
name: 'starRating',
type: 'int'
},
{
name: 'date',
type: 'string'
},
{
name: 'status',
type: 'string'
}
],
proxy:
{
type: 'jsonp',
url: MyApp.util.Config.getBaseUrl() +
'/getReviews.php',
reader:
{
type: 'json',
rootProperty: 'listing'
}
}
}
}
});
我如何拆分我的數據視圖分爲兩個部分,併爲其分配一個標題或標題爲每個部分?謝謝!
感謝您的回覆。我希望在單個選項卡中顯示兩個單獨的框中的單個數據視圖。你是否建議我使用兩個數據視圖,或者有沒有辦法使用相同的數據視圖,但用一定的值填充一個容器並用剩餘的值填充另一個容器? –
您可以有2個不同的數據視圖,但他們都將使用相同的模型和商店。在每個數據視圖模板(tpl)中,您可以使用模板中的{item name}篩選每個數據視圖模板的商店結果。搜索'條件tpl數據視圖',你應該找到一些東西。 – Digeridoopoo