Here is a shortened version of my code :
Ext.define('MyApp.model.Folder', {
extend: 'Ext.data.Model',
fields: ['id', 'name']
});
Ext.define('MyApp.model.User', {
...,
hasMany: { model: 'Folder', name: 'folders' }
});
var form = Ext.widget('form', {
...,
items: {
xtype: 'combo',
name: 'folders',
multiSelect: true,
valueField: 'id',
displayField: 'name',
queryMode: 'local',
store: 'Folders'
}
});
User.load(1, {
success: function (user) {
form.loadRecord(user);
}
});
The data loaded by the User model :
{
...,
folders: [
{ id: 1, name: 'folder 1' },
{ id: 2, name: 'folder 2' }
]
}
Assuming that everything (User model and store) loads successfully, and that the store contains folders 1, 2, N, I want the combo to select the values passed to the loadRecord method (folders 1 and 2), but the field stays empty. Thanks in advance for any help.
I have found a solution just after posting this question. However, I guess this must not be part of the “best practices”, so, waiting for a better one, here is a good alternative :