PDA

View Full Version : How to get selected value from Picker



coverflex
26 Jun 2011, 1:51 AM
I have changed the "Picker" index.js File in Sencha Touch's Examples slightly and want to get the selected value when Button "Done" is tapped or clicked.

What am I doing wrong to get the value?
The innerHTML of textPicker changes to: "Selected Value: [Object object]"

... (added to touch_1.1.0/examples/picker/src/index.js):


var textPicker = new Ext.Panel( {
html: 'Init HTML'
} );

var listPicker = new Ext.Picker( {
height: 300,
cancelButton: 'Abbruch',
doneButton: 'Erledigt',
slots: [{
name: 'limit_speed',
align: 'right',
useTitles: true,
title: 'Uebertragungsgeschwindigkeit',
data: [
{ text: '50 KB/s', value: 50 },
{ text: '100 KB/s', value: 100 },
{ text: '200 KB/s', value: 200 },
{ text: '300 KB/s', value: 300 }
]
}
]
} );

listPicker.on( 'change', function ()
{
var v = listPicker.getValue();
textPicker.body.update( 'Selected Value: ' + v );
} );

kneth
26 Jun 2011, 11:46 PM
Hi! The getValue method of Ext.Picker class always returns an Object which consists of all the values from the slots. So, you can get the selected value by accessing the property limit_speed (slot's name) of the object returned by the getValue method.

Brendan
11 Jul 2011, 8:12 PM
Has this question been answered, I'm having the same issue, where i can see the object, but not whats selected.

-B