Reputation: 445
I have a model and store and I need to assign a value to the hidden field from the store.
Ext.define('loginUser', {
extend: 'Ext.data.Model',
fields: [
{ name: 'id', mapping: 'Provider.id' },
{ name: 'name', mapping: 'Provider.name' }
]
});
loggedUser = Ext.create('Ext.data.Store', {
model: 'loginUser',
autoLoad: true,
proxy: {
type: 'ajax',
url : url+'/lochweb/loch/users/getLoggedUser',
reader: {
type: 'json',
root: 'Users'
}
}
});
I need to assign the store value to hidden field as follows,
CProvider = new Ext.create('Ext.ux.form', {
items: [{
xtype:'hidden',
name:'clearingHouseID',
store:loggedUser
value:id
}]
});
but the value is not assigned to hidden value. Is there any way assign it store value to hidden field?
Thanks
Upvotes: 0
Views: 2382
Reputation: 3887
You can bind a record to a form by using the form's loadRecord function. Something along these lines:
loggedUser.on('load', function (store, records, success) {
if (success && records.length === 1) {
CProvider.loadRecord(records[0]);
}
});
Then change the form field to have a name of the field in the model you want to be stored in the hidden field.
CProvider = new Ext.create('Ext.ux.form', {
items: [{
xtype:'hidden',
name:'name',
store:loggedUser
value:id
}]
});
The hidden field can only store one field's value of the model you are loading into the form.
Upvotes: 1