text: /**
   * @author Andrey Mikhalevich <katrenplus@mail.ru>, 2016
   
   * @class
   * @classdesc Edit control clear value button
  
   * @extends ButtonCtrl 
  
   * @requires core/extend.js
   * @requires controls/ButtonCtrl.js     
    
   * @param {string} id - html tag id
   * @param {namespase} options
   * @param {bool} [options.multySelect=false]
   * @param {Array} options.descrIds
   * @param {Array} options.keyIds
   * @param {function} options.onSelect {namespace} fields is passed as parameter containing all fields
   * @param {function} options.formatFunction {namespace} fields is passed as parameter containing all fields
   */
  function ButtonSelectRef(id,options){
  	
  	options = options || {};
  	this.setMultySelect( (options.multySelect==undefined)? false:options.multySelect );
  	
  	this.m_descrIds = options.descrIds;
  	this.m_keyIds = options.keyIds;
  	
  	this.setOnSelect(options.onSelect);
  	this.setFormatFunction(options.formatFunction);
  	
  	ButtonSelectRef.superclass.constructor.call(this,id,options);
  }
  extend(ButtonSelectRef,ButtonEditCtrl);
  
  /* constants */
  
  /* private methods */
  ButtonSelectRef.prototype.m_multySelect;
  ButtonSelectRef.prototype.m_descrIds;
  ButtonSelectRef.prototype.m_keyIds;
  ButtonSelectRef.prototype.m_onSelect;
  
  /* public methods */
  
  ButtonSelectRef.prototype.getMultySelect = function(){
  	return this.m_multySelect;
  }
  
  ButtonSelectRef.prototype.setMultySelect = function(v){
  	this.m_multySelect = v;
  }
  
  ButtonSelectRef.prototype.onClickEvent = function(e){
  	var win_opts = {};
  	
  	var self = this;
  	win_opts.app = window.getApp();
  	win_opts.onClose = function(){
  		self.closeWinObj();
  	};
  	
  	win_opts.URLParams = this.getWinParams();
  	
  	this.m_winObj = new this.m_winClass(win_opts);
  	var win = this.m_winObj.open();
  	
  	win.onSelect = function(fields){
  		self.onSelect(fields);
  	}	
  }
  
  ButtonSelectRef.prototype.onSelect = function(fields){
  	var ctrl = this.getEditControl();
  	if (ctrl){
  		//keys
  		var ctrl_keys = {};
  		var ctrl_key_ids = ctrl.getKeyIds();
  	
  		var model_key_ids;
  		if (this.m_keyIds){
  			model_key_ids = this.m_keyIds;
  		}
  		else{
  			model_key_ids = this.m_winObj.getKeyIds();				
  		}
  	
  		for (var n=0;n<ctrl_key_ids.length;n++){
  			if (fields[model_key_ids[n]]){
  				ctrl_keys[ctrl_key_ids[n]] = fields[model_key_ids[n]].getValue();
  			}
  		}
  	
  		//descr
  		var ctrl_descr = "";
  		var format_f = this.getFormatFunction();//ctrl.getFormatFunction();
  		if (format_f){
  			ctrl_descr = format_f.call(ctrl,fields);
  		}
  		else if (this.m_descrIds){
  			for (var n=0;n<this.m_descrIds.length;n++){
  				if (fields[this.m_descrIds[n]]){
  					var f_val = fields[this.m_descrIds[n]].getValue();
  					ctrl_descr += (ctrl_descr=="")? "":" ";
  					if (typeof f_val=="object" && f_val.getDescr){
  						ctrl_descr += f_val.getDescr();
  					}
  					else{
  						ctrl_descr += f_val;
  					}
  					
  				}
  			}
  		}
  		else{
  			//no descr field defind. taking all fields, which are not key fields
  			for (var fid in fields){
  				if (!fields[fid].getPrimaryKey()){
  					ctrl_descr += (ctrl_descr=="")? "":" ";
  					ctrl_descr += fields[fid].getValue();
  				}
  			}
  		}
  	
  		ctrl.setValue(new RefType({"keys":ctrl_keys,"descr":ctrl_descr}));
  		ctrl.focus();
  	}
  		
  	if (!this.getMultySelect()){		
  		this.m_winObj.close();
  	}
  	
  	if (this.m_onSelect){
  		this.m_onSelect.call(this,fields);
  	}
  }
  
  ButtonSelectRef.prototype.setOnSelect = function(v){
  	this.m_onSelect = v;
  }
  ButtonSelectRef.prototype.getOnSelect = function(){
  	return this.m_onSelect;
  }
  ButtonSelectRef.prototype.setFormatFunction = function(v){
  	this.m_formatFunction = v;
  }
  ButtonSelectRef.prototype.getFormatFunction = function(){
  	return this.m_formatFunction;
  }
  