PDA

View Full Version : [FIXED] [PR1] Ext.field.Select does not work properly with "store"



subimage
25 Oct 2011, 7:19 PM
No matter what I do, I can't get the "store" option to work with a selectfield.


Ext.define('CbMobile.model.CurrencyType', {
extend: 'Ext.data.Model',
fields: [
{name:'code'},
{name:'name'},
]
});

Ext.define('CbMobile.store.CurrencyTypes', {
extend: 'Ext.data.Store',
model: 'CbMobile.model.CurrencyType',
data: [
{
code: 'USD',
name: 'US Dollar'
}
]
});

// code truncated from the view snippet...
items: [
{
xtype: 'selectfield',
label: 'Currency',
store: 'CurrencyTypes',
valueField:'code',
displayField:'name'
},
{
xtype: 'selectfield',
label: 'Dates',
options: [
{text: 'mm/dd/yyyy', value: 'mm/dd/yyyy'},
{text: 'dd-mm-yyyy', value: 'dd-mm-yyyy'},
{text: 'dd.mm.yyyy', value: 'dd.mm.yyyy'},
{text: 'yyyy/mm/dd', value: 'yyyy/mm/dd'}
]
}
]
// ...more code truncated


The exception I get is constantly related to "getAt". Code trace attached in png file.

28879

joseph09
25 Oct 2011, 9:16 PM
I had trouble getting this to work as well. Here is how I got it to work -



Ext.define('CurrencyType', {
extend: 'Ext.data.Model',
fields: [
{name:'code'},
{name:'name'},
]
});

var CurrencyTypes = Ext.create('Ext.data.Store', {
model: 'CurrencyType',
data: [
{
code: 'USD',
name: 'US Dollar'
}
]
});

// code truncated from the view snippet...
items: [
{
xtype: 'selectfield',
label: 'Currency',
store: CurrencyTypes,
valueField:'code',
displayField:'name'
},
]
// ...more code truncated



Hopefully someone can post the proper way to accomplish this

subimage
25 Oct 2011, 10:15 PM
Thanks for that. What puzzles me is that I have a List component that I'm using a store in. I've defined that store the exact same way and it works.

The inconsistency of the usage of a store on the Select field is troublesome.

subimage
26 Oct 2011, 8:02 PM
I got it to work by doing this...




{
xtype: 'selectfield',
label: 'Currency',
store: Ext.create('CbMobile.store.CurrencyTypes'),
valueField:'code',
displayField:'name'
}



...instead of this.




{
xtype: 'selectfield',
label: 'Currency',
store: 'CbMobile.store.CurrencyTypes',
valueField:'code',
displayField:'name'
}



Again - WHY does it work this way on Ext.field.Select, when it works the 2nd way on Ext.dataview.List?


Definitely a bug from where I'm sitting. Make it consistent.

Jamie Avins
31 Oct 2011, 12:04 PM
The Data package is currently in the process of being cleaned up and should resolve this problem. I agree this should be consistent throughout and it will be addressed before a final release.