【发布时间】:2017-11-08 19:19:39
【问题描述】:
寻找一些关于如何根据所选选项卡从不同数据存储区动态加载数据的建议。
两个存储具有相同的列名,因此加载 dataIndex 不需要更改。
选择“当前”选项卡时,我想绑定商店“当前”
选择“完成”选项卡时,我想绑定商店“已完成”
我的代码示例如下:
viewModel: {
formulas: {
activeStore: function(get) {
var active = get('active');
return this.getStore(active == 'aTab' ? 'a' : 'b');
}
},
data: {
active: 'aTab'
},
stores: {
a: 'Change',
b: 'ChangeArchive',
}
},
{
xtype: 'tabpanel',
id: 'changetabs',
tabBarHeaderPosition: 1,
headerPosition: 'top',
plain: true,
width: 480,
height: 30,
items: [{
title: 'Current',
itemId: 'aTab'
},
{
title: 'Completed',
itemId: 'bTab'
}
],
listeners: {
tabchange: function(tabPanel, newTab) {
tabPanel.ownerCt.getViewModel().set('active', newTab.getItemId());
}
}
},
还有网格
{
region: 'west',
xtype: 'grid',
bind: {store: '{activeStore}'},
viewConfig: {
markDirty: false
},
id: 'ActionList',
columns: {
items: [
{ text: 'Action', dataIndex: 'action_id', width: 300},
{ text: 'Status', dataIndex: 'status', width: 180},
]
},
listeners: {
select: 'onSelectAction'
}
}
【问题讨论】:
-
在你的虚拟机中有一些表示活动选项卡的键。有一个 tabchange 的监听器并戳那个键,然后编写一个公式以根据所述键返回正确的存储。