【发布时间】:2026-01-31 11:55:01
【问题描述】:
请看下面的小提琴:Bind store from a ViewModel to an xtype label
我无法从 ViewModel 的商店中获取记录以显示在表单的 xtype: 'label' 项中。
这应该很容易,但是我的大脑无法工作......
【问题讨论】:
标签: extjs data-binding viewmodel
请看下面的小提琴:Bind store from a ViewModel to an xtype label
我无法从 ViewModel 的商店中获取记录以显示在表单的 xtype: 'label' 项中。
这应该很容易,但是我的大脑无法工作......
【问题讨论】:
标签: extjs data-binding viewmodel
无法为商店的第一条记录创建绑定描述符。为此,您需要实现formula。
在您的视图模型中:
formulas: {
firstTestStoreRecord: {
bind: '{testStore}',
get: function(testStore) {
return testStore.getAt(0);
}
}
}
然后在你的视图中使用它:
bind: {
html: '<b>{firstTestStoreRecord.test}</b>'
}
【讨论】:
在 7.4 版中:
bind: {
html: '<b>{testStore.first.test}</b>'
}
【讨论】: