Download default value for comboBox extjs

how can I load the default value from my json store (remote) to combobox, I tried loading the storage before rendering the combo and using setValue () I want my combo to display the first result in the PLZ store tell me the correct way to do this, and thanx

+6
javascript extjs combobox store
source share
1 answer

You need to set the value property to the value the first element after loading the store

 Ext.ns('MyNamespace'); MyNamespace.MyComboBox = Ext.extend(Ext.form.ComboBox, { displayField: 'displayValue', triggerAction: 'all', valueField: 'ID', initComponent: function () { this.store = new Ext.data.JsonStore({ url: 'url', baseParams: { //params }, fields: [ {name:'ID', mapping: 'ID', type: 'int'}, {name:'displayValue', mapping: 'displayValue', type: 'string'}, ], root: 'root' }); var me = this; this.store.on('load',function(store) { me.setValue(store.getAt(0).get('ID')); }) MyNamespace.MyComboBox.superclass.initComponent.call(this); this.store.load(); } }); 
+14
source share

All Articles