Ext combobox select after store reboot does not work properly

Here is my combobox configuration

{ xtype : 'combo', fieldLabel : 'Select Field', displayField : 'field_name', valueField : 'field_id', id : 'fields_combo_id', store: new Ext.data.JsonStore({ proxy : new Ext.data.HttpProxy({url:eyefind.config.DATA_RETRIEVAL, method:'GET'}), baseParams: { subject: 'fields' }, root: 'data', id: 'field_id', fields: ['field_name'], autoload: true }), labelStyle : 'font-weight:bold; width:100px', triggerAction : 'all', clearFilterOnReset : false, mode : 'local' } 

I load the repository into an external function as follows:

  ..... var comboFields = Ext.getCmp('fields_combo_id'); comboFields.store.load(); comboFields.setValue(selectedFieldId); ..... 

And while selectedFieldId is selected, but in the visible part I see a value instead of a displayText, the store looks fine, and I set the value:displayValue pair value:displayValue .

Am I missing something or do I need to use some other functions for this part?

My version of Ext is 3.2.0.

+4
source share
2 answers

You set valuefield : 'field_id' , but there are no fields in fields fields ,

 { xtype : 'combo', fieldLabel : 'Select Field', displayField : 'field_name', valueField : 'field_id', //This 'field_id' must be in store fields too. id : 'fields_combo_id', store: new Ext.data.JsonStore({ proxy : new Ext.data.HttpProxy({url:eyefind.config.DATA_RETRIEVAL, method:'GET'}), baseParams: { subject: 'fields' }, root: 'data', id: 'field_id', //This id is just for the store, not the record data. fields: ['field_id','field_name'], // here, i add `field_id` autoload: true // This should be autoLoad, remember JavaScript is case sensitive. }), labelStyle : 'font-weight:bold; width:100px', triggerAction : 'all', clearFilterOnReset : false, mode : 'local' } 

And also, why do you set autoLoad : true if you load it again into your external function?

EDIT

When I run comboFields.setValue(id); , in which my identifier is assigned to one of the field identifiers, it works, and I see the display field in my combo (there is no need for a drop-down list first). But, if in your case your combo element was highlighted, I think this is due to the version. Unfortunately, I tested it in Ext 3.3.0.

+3
source

Try using the following code.

 var selectedFieldValue = Ext.getCmp('fields_combo_id').getRawValue(); var selectedFieldId = Ext.getCmp('fields_combo_id').getValue(); comboFields.setValue(selectedFieldId,selectedFieldValue); 
0
source

All Articles