jsm

net/sf/jsm/table/jsmActionCell.js

Summary

No overview generated for 'net/sf/jsm/table/jsmActionCell.js'


Class Summary
JsmActionCell An action table data cell

  
/**
 * An action table data cell
 * @extends JsmCell
 * @class An action table data cell
 * @param value Optional: The value can be a string or an object with a getNode() method
 * @param title Optional: The title 
 * @constructor
 */      
  function JsmActionCell(value, title) {
    /** @ignore */  
  	this.id=new Date().getTime() + "" + Math.random();   
  	logger.info("Created JsmActionCell with id: " + this.id);  		
    /** @ignore */       
    this.value = jsm.noud(value)?"":value;
    /** @ignore */       
    this.title = jsm.noud(title)?value:title;       	   	
  }
  JsmActionCell.extendClass(JsmCell);
  /** @ignore */    
  JsmActionCell.prototype.className="JsmActionCell";
 
  /** The init method will be called while rendering before the getNode method.
  * Does not have to be implemented
  * @param {JsmTable} table The table object
  * @param {int} rowIdx The index of the row
  * @param {int} columnIdx The index of the column     
  * @return this
  */       
  JsmActionCell.prototype.init = function(table, rowIdx, columnIdx) {
  	return this;
  }  
  
  /** Get the node object; the model (this) will be attached to the node as property 'model'
  * @param specialClassName The name of the special style class  
  * @param jsmRowType The value of the meta data 'jsmRowType' of the td's row   
  * @return The created node object
  */       
  JsmActionCell.prototype.getNode = function(specialClassName, jsmRowType) { 
	if (!jsm.noud(jsmRowType) && jsmRowType == 'header') {
		var cell = document.createElement("th");
	} else {
		var cell = document.createElement("td");
	}	
  	cell.setAttribute("id", this.id);  
  	cell.model=this;  		 
  	this.addAttributesToViewComponent(cell); 
  	if (jsm.noud(jsmRowType) || jsmRowType != 'header') {
	  	//add default class 'jsmEven' or 'jsmOdd'
	  	if (jsm.noud(this.getAttribute('class'))) {
			cell.className=(this.tr.table._nodeIterationCounter%2==0?'jsmEven':'jsmOdd');
	  	} else {
			cell.className=this.getAttribute('class') + (this.tr.table._nodeIterationCounter%2==0?' jsmEven':' jsmOdd');  	
	  	}
	}	
  	cell.onclick=_jsmOnClickEventDelegate;
  	cell.onmousedown=_jsmOnMouseDownEventDelegate;
	cell.onmouseup=_jsmOnMouseUpEventDelegate;
  	cell.setAttribute("title", this.title);
  	//add content
  	if (typeof this.value == 'string') {
		if (this.value.indexOf('%{') == 0) {
	 		var expression = this.value.substring(2, this.value.length-1);
			cell.innerHTML=eval(expression);
	  	} else {
		  	cell.innerHTML = this.value;  	
	  	}	
  	}
  	if (typeof this.value == 'object') {
	 	cell.appendChild(this.value.getNode());	
	} 
  	return cell;
  }    	   	
  
  /** Creates a new JsmActionCell object and copies the values
  * @return {JsmActionCell} The cloned object object
  */       
   JsmActionCell.prototype.clone = function() {
   		var clonedActionCell = new JsmActionCell();
   		//TODO is it sufficient to copy the Array or do we have to iterate and copy each entry
   		clonedActionCell._attributes = this._attributes;
   		clonedActionCell._metaData = this._metaData;   
   		clonedActionCell.init=this.init;		
   		clonedActionCell.value = this.value;   		
   		clonedActionCell.title = this.title; 
   		clonedActionCell.onClickFunctionName = this.onClickFunctionName;    		
   		return clonedActionCell;		
   } 
  

jsm

Documentation generated by JSDoc on Tue Sep 26 08:42:57 2006