PDA

View Full Version : Get selected slot from a picker



BackgroundTeam
17 Apr 2012, 2:37 AM
Good morning to everyone,

I have this code:


var picker = Ext.Viewport.add({
xtype: 'picker',
slots: [{
name: 'years',
title: 'Select age',
data: [
{ text: '1910s', value: 1910 },
{ text: '1920s', value: 1920 },
{ text: '1930s', value: 1930 },
{ text: '1940s', value: 1940 },
{ text: '1950s', value: 1950 },
{ text: '1960s', value: 1960 },
{ text: '1970s', value: 1970 },
{ text: '1980s', value: 1980 },
{ text: '1990s', value: 1990 },
{ text: '2000s', value: 2000 },
{ text: '2010s', value: 2010 }
]
}],
listeners: {
change: function(){
console.log(picker.getValue());
}
}
}).show();




How do I get the value of the slot I selected. When I do this, I get this in the console:

[Object object], and not, for example: 1910.

Thank you very much in advance.

scottmartin
17 Apr 2012, 5:22 AM
Change your listener to include your parameter and have a look at the data:

change( Ext.form.field.Field this, Object newValue, Object oldValue, Object eOpts )
so:
change function(field,newValue,oldValue){ .. }

Regards,
Scott.

BackgroundTeam
19 Apr 2012, 2:32 AM
Thank you so much, Scott.

Finally I turned into choosing the selectfield instead.

burrellramone
3 Aug 2012, 8:27 AM
Thank you so much, Scott.

Finally I turned into choosing the selectfield instead.







I'm thinking of doing that right now. :-)