How I can to get index of selected Ext.form.field.PickerView item? I am trying to use it:
Ext.define('Bind.CL.FormD.view.MyCombo', {
extend: 'Ext.form.field.Picker',
alias: 'widget.mycombo',
...something code...
this.on('expand', function () {
var combo = Ext.ComponentQuery.query('mycombo')[0];
var value = combo.getValue(); //or getRawValue();
}, this);
But it doesn't work..
You can use indexOf() function:
Please Check Fiddle : https://fiddle.sencha.com/#fiddle/1i0o
Ext.application({
name: 'Fiddle',
launch: function() {
simpsonsStore = Ext.create('Ext.data.Store', {
storeId : 'simpsonsStore',
fields : ['id','name', 'email'],
data : [
{name : 'Lisa',email : '[email protected]',id:1},
{name : 'Bart', email : '[email protected]',id:2},
{name : 'Homer', email : '[email protected]',id:3},
{name : 'Marge',email : '[email protected]',id:4}
]
});
Ext.create('Ext.form.field.ComboBox', {
emptyText: "Hello",
growMax: 10,
valueField: 'id',
store:simpsonsStore,
displayField: 'name',
editable: false,
queryMode: 'local',
renderTo: Ext.getBody(),
listeners:{
change:function(combo){
console.log(combo.store.indexOf((combo.store.getById(combo.value))));
}
}
});
}
});