私は次のモデルを持っています:
Ext.define('myApp.model.tool.SpecialModel', {
extend: 'Ext.data.Model',
fields: [
{name: 'id', type: 'string'},
{name: 'loginName', type: 'string'},
{name: 'firstName', type: 'string'},
{name: 'lastName', type: 'string'},
],
proxy: {
type: 'rest',
url: '/special/url',
reader: {
type: 'json'
}
}
});
そして、このViewModel:
Ext.define('myApp.view.support.MySpecialViewModel', {
extend: 'Ext.app.ViewModel',
alias: 'viewmodel.myspecial',
stores: {
session: {
model: 'myApp.model.tool.SpecialModel'
}
}
});
そして、このビュー:
Ext.define('myApp.view.support.MySpecialView', {
extend: 'Ext.toolbar.Toolbar',
viewModel: 'myspecial',
config: {
items: [
{
xtype: 'button',
bind: '{session.lastName}',
menu: [
{
text: 'My Profile',
handler: 'onProfileClick'
}
]
}
]
},
});
ビューがレンダリングされた時点で、ストアはすでにいっぱいです。指定した ViewModel の lastName がボタンに表示されないのはなぜですか? インラインデータを試してみるとうまくいきます。
前もって感謝します。
編集:ボタンバインディングを次のように変更すると
...
xtype: 'button',
bind: 'Hello, {session.lastName}',
menu: [
{
text: 'My Profile',
handler: 'onProfileClick'
}
]
...
ハードコードされた文字列も表示されません。ここで何が欠けていますか?
編集2:
これが私のjsonデータです:
{
"privileges": {
"privManageCustomer": true,
"privManageCustomerAccount": true,
},
"user": {
"accountLocked": false,
"accountLockedAt": null,
"customerId": "12123213213123",
"email": "213213",
"failedLogins": 0,
"firstName": null,
"id": "123678213621783",
"languageId": "de",
"lastFailedLogin": null,
"lastLogin": null,
"lastName": "Whatever",
"loginName": "test123"
}
}