Ext.define('uas.override.form.field.ComboBox', { override: 'Ext.form.field.ComboBox', displayField: 'text', valueField: 'value', queryMode: 'local', // 加载数据后直接将第一行设置为默认值 selectFirstIfNull: false, onLoad: function (store, records, success) { var me = this; if (!me.value && me.selectFirstIfNull && store.getCount()) { var value = store.first().get(me.valueField); me.value = me.multiSelect ? [value] : value; } // This flag is saying that we need to call setValue to match the value property with the // just loaded record set and update the valueCollection (and thereby any bound ViewModel) // with that matched record. var needsValueUpdating = !me.valueCollection.byValue.get(me.value); // If not returning from a query, and the value was set from a raw data value, unrelated to a record // because the displayField was not honoured when calculating the raw value, then we update // the raw value. if (success && needsValueUpdating && !me.isPaging && !(store.lastOptions && 'rawQuery' in store.lastOptions)) { me.setValueOnData(); } // This synchronizes the value based upon contents of the store me.checkValueOnChange(); me.isPaging = false; }, constructor: function(config) { var me = this; config = config || {}; if (!config.store) { config.store = { fields: [me.displayField, me.valueField], data: me.options } } me.callParent([config]); }, setOptions: function(options) { var me = this, store = me.getStore(); if (null == store) { me.setStore({ fields: [me.displayField, me.valueField], data: options }); } else { store.loadData(options); } } });