Hi, I am trying to bind a 'User' model to a form view when somebody clicks an actioncolumn button in a grid. I am trying to use links + reference config in ViewModel:
User model:
This does not work. It issues a request to fetch user with given id, but the binding never happens.
Moreover, the following piece of code (which I found in ViewModel jsdoc) does not work, the callbacks never get called eventhough requests are made to server to fetch users with id 1 and 2.
Off course, if i try to manually load the record by id and bind it to ViewModel, everything works as expected.
I've also tried using all kinds of session configs (session: new Ext.data.Session(), session: true, without session) on views (parent or only detail) with no success.
I also have to mention i've tried using both extjs-5.0.0.736 and extjs-5.0.0.970, the latter being commercial version.
Code:
onEditUser: function (id) {
if (this.getView()) {
this.getView().removeAll();
this.getView().add(Ext.create('GE.view.user.UserDetailView', {
links: {
theUser: {
reference: 'GE.model.user.User',
id: id
}
}));
}
},
User model:
Code:
Ext.define('GE.model.user.User', {
extend: 'GE.model.Base',
idProperty: 'id',
fields: [
'firstName',
'lastName',
{
name: 'name', convert: function (value, record) {
return record.get('firstName') + ' ' + record.get('lastName');
}
},
'username',
'password',
'email',
'phone'
],
proxy: {
url: '/user'
}
});
This does not work. It issues a request to fetch user with given id, but the binding never happens.
Moreover, the following piece of code (which I found in ViewModel jsdoc) does not work, the callbacks never get called eventhough requests are made to server to fetch users with id 1 and 2.
Code:
var rec = new GE.model.user.User({
id: 2,
firstName: 'Ned',
lastName: 'Stark'
});
var viewModel = Ext.create('Ext.app.ViewModel', {
session: new Ext.data.Session(),
links: {
theUser: {
reference: 'GE.model.user.User',
id: 1
},
otherUser: rec
}
});
viewModel.bind('{theUser.firstName}', function(v) {
console.log(v);
});
viewModel.bind('{otherUser.firstName}', function(v) {
console.log(v);
});
Off course, if i try to manually load the record by id and bind it to ViewModel, everything works as expected.
I've also tried using all kinds of session configs (session: new Ext.data.Session(), session: true, without session) on views (parent or only detail) with no success.
I also have to mention i've tried using both extjs-5.0.0.736 and extjs-5.0.0.970, the latter being commercial version.
Thanks,
Marius
Aucun commentaire:
Enregistrer un commentaire