Ext.define('amdaUI.ColorMap', { extend: 'Ext.form.ComboBox', alias: 'widget.colormap', data : [], onValueChange: null, constructor:function(config){ this.getData(); this.init(config); this.callParent(); }, getData:function(){ var me = this; amdaDefaultConfigs.availableColorMaps.forEach(function(color){ me.data.push({key:color.key,name:color.value, iconUrl:'generic_data/colormaps/'+ color.svgFile}) }); }, init: function(config){ var me = this; var size = (typeof config !== "undefined" && config.size) ? config.size : '12'; var hideFieldLabel = true; if (typeof config !== "undefined") { hideFieldLabel = (config.hideFieldLabel !== false); } Ext.apply(this,{ xtype:'combobox', name: (typeof config !== "undefined" && config.name) ? config.name:null, fieldLabel: hideFieldLabel ? '' : 'Color Map 
\ \ \
', editable: false, queryMode: 'local', onValueChange: (typeof config !== "undefined" && config.onValueChange) ? config.onValueChange : null, listeners: { change: function (combo, newValue, oldValue, eOpts) { var iconUrl=""; var colorName = ""; me.data.forEach(function(colorData){ if(colorData.key == newValue ){ iconUrl= colorData.iconUrl; colorName = colorData.name; } }); combo.inputEl.setStyle('background-image', 'url(' + iconUrl + ')'); combo.inputEl.setStyle('background-size', '100%'); combo.inputEl.setStyle('background-repeat', 'no-repeat'); combo.inputEl.setStyle('background-position', 'center'); combo.inputEl.setStyle('font-size', '0'); combo.inputEl.set({ "data-qtip": Ext.String.htmlDecode(colorName) }); if (me.onValueChange) me.onValueChange(me.name, newValue, oldValue); }, click: { element: 'el', fn: function(e,t) { var me = t, text = me.getAttribute('amda_clicktip'); if (text) { e.preventDefault(); AmdaAction.getInfo({name : text}, function(res,e) { if (res.success) myDesktopApp.infoMsg(res.result); }); } } }, scope:this }, }) } });