PDA

View Full Version : ComboBox values not in the store



tellniko
24 Oct 2011, 11:43 PM
Hi guys, I can't solve my problem and I decided to post it here. There is my simple store store and combobox:
data = [];
for (i = 0,j = 0; i < 12; i++, j += 5)
data.push({value: j , text: ''+j+ ' minutes'});
Project.minutes = Ext.create('Ext.data.Store', {
fields: ['value', 'text'],
data : data
});

...
xtype: 'combo',
emptyText: 'Minutes',
store: Project.minutes,
valueField: 'value',
displayField: 'text',
id: 'ActualDurationMinutes'
...
The problem comes when I try to input a value different from these in the store and then reload the dialog window.

Ext.getCmp('ActualDurationMinutes').getValue();
RESULT: 2

The Value is the same but it is not shown in the field and also brakes my validation. What I am supposed to do in this situation? Maybe try to add it dynamically in the store and after that remove it?
28857288582885928860

twaindev
25 Oct 2011, 5:57 AM
Perhaps this might help:


Ext.onReady(function() {

Ext.widget('combobox', {
renderTo: Ext.getBody(),
store: [1,5,10,15,30,45],
forceSelection: false,
autoSelect: false,
displayTpl: '<tpl for=".">{[typeof values === "number" ? values : values["field1"]]} minutes</tpl>',
listConfig: {
getInnerTpl: function(displayField) {
return '{' + displayField + '} minutes';
}
},
beforeBlur: function() {
var me = this,
value = parseInt(me.getRawValue(),10);
me.doQueryTask.cancel();
if(value) {
me.setValue(value);
}
me.assertValue();
}
}).center();
});
It uses an array/store with numeric values. The 'minutes' text is only added for display purposes.
28869