Ext.define('Portfolio.designer.ui.domainModelEntityColumnComboBox', {
	extend: 'Ext.form.field.ComboBox',
	alias: ['widget.ip2DomainModelEntityColumnComboBox'],
	displayField: 'name',
	valueField: 'name',
	emptyText: ip2.i18n('selectColumn'),
	queryMode: 'local',
	initComponent: function() {

		var me = this;

		me.tpl = me.getListTemplate();
		me.displayTpl = me.getDisplayTemplate();
		me.callParent();
	},
	getListTemplate: function() {

		var i_tpl = Ext.create('Ext.XTemplate',
			'<tpl for=".">',
				'<li role="option" class="x-boundlist-item" style="text-overflow: ellipsis; white-space: nowrap; overflow:hidden;">',
					'<span>{name}</span> ( <span>{[this.getValue(values.title)]}</span> )',
				'</li>',
			'</tpl>',
			{
				getValue: function(o_value) {

					var value = Ext.isObject(o_value) ? ip2.i18n(o_value) : o_value;
					return value;
				}
			}

		);
		return i_tpl;
	},
	getDisplayTemplate: function() {

		var i_self = this;

		var i_tpl = Ext.create('Ext.XTemplate',
			'<tpl for=".">',
				'{[typeof values === "string" ? values : this.renderer(values)]}',
				'<tpl if="xindex < xcount">' + i_self.delimiter + '</tpl>',
			'</tpl>',
			{
				renderer: function(o_values) {

					return o_values[i_self.displayField] + " ( " + ip2.i18n(o_values.title) + " )";
				}
			}
		);
		return i_tpl;
	}

});
