threethazz
2 Nov 2011, 5:52 AM
Hello,
I'm having an interesting "feature" with my combobox. This combobox needs to:
1) have a displayField and a valueField [not sure if working]
2) allow selection of other values from the list [not working]
3) automatically load one value to the box. [working]
What happens in Point (2) is that the drop down shows me 3 correct values but after selection actually doesn't update the value chosen in the box nor fires the alert message.
here's some code:
if (!Ext.ClassManager.isCreated('Company')){
Ext.define('Company',{
extend: 'Ext.data.Model',
fields: [
'name', 'company_id',
]
});
}
var companiesStore = Ext.create('Ext.data.Store', {
model: 'Company',
autoLoad: true,
proxy: {
type: 'ajax',
url: 'Company',
reader: {
type: 'json',
root: 'list'
} }
});
companiesStore.on({
'load': {
fn: function(companiesStore){
customTplCombo.setValue(companiesStore.getAt(0).get('company_id')); }, scope:this }
});
var customTplCombo = Ext.create('Ext.form.field.ComboBox', {
id: 'combobx',
fieldLabel: 'Select a Company',
renderTo: 'ComboBox',
displayField: 'name',
valueField: 'company_id',
hiddenName: 'company_id',
width: 300,
labelWidth: 130,
store: companiesStore,
allowBlank: false,
queryMode: 'local',
listeners:{
scope: this,
'select': function(){
var comboV = Ext.getCmp('combobx');
alert(comboV.getRawValue());
}
}
});
Thank you in advance!
threethazz
I'm having an interesting "feature" with my combobox. This combobox needs to:
1) have a displayField and a valueField [not sure if working]
2) allow selection of other values from the list [not working]
3) automatically load one value to the box. [working]
What happens in Point (2) is that the drop down shows me 3 correct values but after selection actually doesn't update the value chosen in the box nor fires the alert message.
here's some code:
if (!Ext.ClassManager.isCreated('Company')){
Ext.define('Company',{
extend: 'Ext.data.Model',
fields: [
'name', 'company_id',
]
});
}
var companiesStore = Ext.create('Ext.data.Store', {
model: 'Company',
autoLoad: true,
proxy: {
type: 'ajax',
url: 'Company',
reader: {
type: 'json',
root: 'list'
} }
});
companiesStore.on({
'load': {
fn: function(companiesStore){
customTplCombo.setValue(companiesStore.getAt(0).get('company_id')); }, scope:this }
});
var customTplCombo = Ext.create('Ext.form.field.ComboBox', {
id: 'combobx',
fieldLabel: 'Select a Company',
renderTo: 'ComboBox',
displayField: 'name',
valueField: 'company_id',
hiddenName: 'company_id',
width: 300,
labelWidth: 130,
store: companiesStore,
allowBlank: false,
queryMode: 'local',
listeners:{
scope: this,
'select': function(){
var comboV = Ext.getCmp('combobx');
alert(comboV.getRawValue());
}
}
});
Thank you in advance!
threethazz