PDA

View Full Version : ComboBox shows value on drop down.



Michael7101
2 Jul 2013, 11:42 AM
I have a combo box in a grid and when I drop down the selector A value still appears in the field. The value is the id and not the display value however. So if my box has Yes No value I will see the value of 1 or 0 (or true and false if datatype is bool) in the field. Its kind of confusing. Does anyone know how to fix that or make the value clear during selection. Thanks,

Here is my grid combobox code/;

{
id: 'idenabled',
header: 'Enabled',
width: 60,
dataIndex: 'enabled',
value: '',
valueField:'id',
displayField:'value',
disabled: false,
editor:
{ xtype: 'combobox',
typeAhead: false,
// hideactive: true,
disabled: false,
selectOnTab: true,
triggerAction: 'all',
fields:['id','value'],
store: BSSEnabledStore,
value: '',
valueField:'id',
displayField:'value',
multiSelect: false,
queryMode: 'local',
lazyRender: true,
listClass: 'x-combo-list-small',


listeners: {
expand: function(){
alert('e clicked');
}
}


},
renderer: function(val) {var matching = BSSEnabledStore.queryBy( function(rec){ return rec.data.id == val; }); return (matching.items[0]) ? matching.items[0].data.value : ''}
}


44665

slemmon
4 Jul 2013, 11:02 AM
Try setting the valueField to 'value' as well:



Ext.create('Ext.data.Store', {
storeId:'simpsonsStore',
fields:['name', 'email', 'phone'],
data:{'items':[
{"name":"Lisa", "email":"lisa@simpsons.com", "phone":"555-111-1224"},
{"name":"Bart", "email":"bart@simpsons.com", "phone":"555-222-1234"},
{"name":"Homer", "email":"home@simpsons.com", "phone":"555-222-1244"},
{"name":"Marge", "email":"marge@simpsons.com", "phone":"555-222-1254"}
]},
proxy: {
type: 'memory',
reader: {
type: 'json',
root: 'items'
}
}
});


Ext.create('Ext.grid.Panel', {
title: 'Simpsons',
store: Ext.data.StoreManager.lookup('simpsonsStore'),
columns: [
{header: 'Name', dataIndex: 'name', editor: 'textfield'},
{header: 'Email', dataIndex: 'email', flex:1,
editor: {
xtype: 'combobox',
editable: false,
forceSelection: true,
store: {
fields: ['id', 'value'],
data: [{
id: '1',
value: 'Yes'
}, {
id: '0',
value: 'No'
}]
},
valueField: 'value',
displayField: 'value',
queryMode: 'local',
listClass: 'x-combo-list-small',
listeners: {
expand: function () {
//alert('e clicked');
}
}
}
},
{header: 'Phone', dataIndex: 'phone'}
],
selType: 'cellmodel',
plugins: [
Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
})
],
height: 200,
width: 400,
renderTo: Ext.getBody()
});