jsm

net/sf/jsm/table/util/jsmActionCells.js

Summary

Contains default header/footer/row action cell definitions


Method Summary
static private  void _jsmHideTable(<JsmTable> table, <int> rowIdx, <int> columnIdx)
           Will be called by the jsmHideTableActionCell
static private  void _jsmOnAddRow(<JsmTable> table)
           Will be called by the jsmAddRowActionTh
static private  void _jsmOnDeleteRow(<JsmTable> table, <int> rowIdx)
           Will be called by the jsmDeleteRowActionTd
static private  void _jsmOnEditRow(<JsmTable> table, <int> rowIdx, <int> columnIdx)
           Will be called by the jsmEditRowActionTd
static private  void _jsmOnGotoFirstPage(<JsmTable> table, <int> rowIdx, <int> columnIdx)
           Will be called by the jsmGotoFirstPageActionCell
static private  void _jsmOnGotoLastPage(<JsmTable> table, <int> rowIdx, <int> columnIdx)
           Will be called by the jsmGotoLastPageActionCell
static private  void _jsmOnGotoNextPage(<JsmTable> table, <int> rowIdx, <int> columnIdx)
           Will be called by the jsmGotoNextPageActionCell
static private  void _jsmOnGotoPreviousPage(<JsmTable> table, <int> rowIdx, <int> columnIdx)
           Will be called by the jsmGotoPreviousPageActionCell
static private  void _jsmOnSaveRow(<JsmTable> table, <int> rowIdx, <int> columnIdx)
           Will be called by the jsmEditRowActionTd
static private  void _jsmShowOnlyHeader(<JsmTable> table, <int> rowIdx, <int> columnIdx)
           Will be called by the jsmShowOnlyHeaderActionTh
static void jsmOnAddRow(<JsmTable> table, <int> rowIdx)
           Will be called by the after the the add row button has been clicked; define your own version of this function if needed
static void jsmOnDeleteRow(<JsmTable> table, <int> rowIdx)
           Will be called by the after the the delete button has been clicked; define your own version of this function if needed
static void jsmOnEditRow(<JsmTable> table, <int> rowIdx)
           Will be called by the after the the edit button has been clicked; define your own version of this function if needed
static void jsmOnSaveRow(<JsmTable> table, <int> rowIdx)
           Will be called by the after the the save button has been clicked; define your own version of this function if needed

/**
 * @fileoverview Contains default header/footer/row action cell definitions
 */
 
/** A row action cell: Makes the rows editable */
	 jsmEditRowActionCell = new JsmActionCell("<img src='" + jsmEditImage + "' border='0'></img>").setTitle(jsmTitleEdit).setOnClick('_jsmOnEditRow');
	 jsmEditRowActionCell.init = function(table, rowIdx, columnIdx) {
	 	if (rowIdx==-1) {return;}	 
	 	if (this.getRow(rowIdx).isEditMode()) {
			table.getRow(rowIdx).getActionCell(columnIdx).setValue("<img src='" + jsmSaveImage + "' border='0'></img>");
	  		table.getRow(rowIdx).getActionCell(columnIdx).setOnClick("_jsmOnSaveRow").setTitle(jsmTitleSave); 	
	 	} else {
			table.getRow(rowIdx).getActionCell(columnIdx).setValue("<img src='" + jsmEditImage + "' border='0'></img>");	  		
		  	table.getRow(rowIdx).getActionCell(columnIdx).setOnClick("_jsmOnEditRow").setTitle(jsmTitleEdit); 	
	 	}
	 }  	
	 
	/**
	 * Will be called by the jsmEditRowActionTd
	 * @param {JsmTable} table The table object
	 * @param {int} rowIdx The index of the row
	 * @param {int} columnIdx The index of the column 
	 * @private
	 */
	  function _jsmOnEditRow(table, rowIdx, columnIdx) {
	    //save rows currently in edit mode
	  	table.saveAllRowsInEditMode();
	    //reset edit mode for all rows  	 
	 	table.cleanUpAfterSave();
	  	table.getRow(rowIdx).setEditMode(true);
	  	table.render(); 
		table.focusOnFirstWidget();	 
	  	//call user event 
	  	jsmOnEditRow(table, rowIdx);
	  } 
  
	/**
	 * Will be called by the jsmEditRowActionTd
	 * @param {JsmTable} table The table object
	 * @param {int} rowIdx The index of the row
	 * @param {int} columnIdx The index of the column  
	 * @private
	 */  
	  function _jsmOnSaveRow(table, rowIdx, columnIdx) {
	  	for (var widgetColumnIdx=0;widgetColumnIdx<table._columnIdx2Widget.length;widgetColumnIdx++) {
	  		var widget = table._columnIdx2Widget[widgetColumnIdx];
	  		widget.updateModel(table, rowIdx, widgetColumnIdx, $(widget.getId()))
	  	}    	
	  	table.cleanUpAfterSave();
	  	table.render(); 
	  	//call user event  
		jsmOnSaveRow(table, rowIdx); 	
	  }  	 
	  
	/**
	 * Will be called by the after the the edit button has been clicked; define your own version of this function if needed
	 * @param {JsmTable} table The table object
	 * @param {int} rowIdx The index of the row
	 */     
	  function jsmOnEditRow(table, rowIdx) {
	  }  
	  
	/**
	 * Will be called by the after the the save button has been clicked; define your own version of this function if needed
	 * @param {JsmTable} table The table object
	 * @param {int} rowIdx The index of the row
	 */   
	  function jsmOnSaveRow(table, rowIdx) {
	  	table.getRow(rowIdx).setDirty(false);
	  }  

/** A row action cell: Makes the rows deleteable */ 
	 jsmDeleteRowActionCell = new JsmActionCell("<img src='" + jsmDeleteImage + "' border='0'></img>").setTitle(jsmTitleDelete).setOnClick('_jsmOnDeleteRow');
	 
	/**
	 * Will be called by the jsmDeleteRowActionTd
	 * @param {JsmTable} table The table object
	 * @param {int} rowIdx The index of the row
	 * @private
	 */  
	  function _jsmOnDeleteRow(table, rowIdx) {
	    //save rows currently in edit mode
	  	table.saveAllRowsInEditMode();  
	    //reset edit mode for all rows  	
	 	table.cleanUpAfterSave();  	 
	  	if (!confirm(jsmAlertConfirmDelete)) {return;}
	  	logger.debug("ActionCell: _jsmOnDeleteRow: Remove row: " + rowIdx);
	  	table.removeRow(rowIdx);
	  	table.render(); 
	  	//call user event  
		jsmOnDeleteRow(table, rowIdx);
	  } 	 
	  
	/**
	 * Will be called by the after the the delete button has been clicked; define your own version of this function if needed
	 * @param {JsmTable} table The table object
	 * @param {int} rowIdx The index of the row
	 */   
	  function jsmOnDeleteRow(table, rowIdx) {
	  }  

/** A header/footer action cell: Allows to add new rows */ 
	 jsmAddRowActionCell = new JsmActionCell("<img src='" + jsmAddImage + "' border='0'></img>").setTitle(jsmTitleAdd).setOnClick('_jsmOnAddRow');  
		 
	/**
	 * Will be called by the jsmAddRowActionTh
	 * @param {JsmTable} table The table object
	 * @private
	 */    
	  function _jsmOnAddRow(table) {
	    //save rows currently in edit mode
	  	table.saveAllRowsInEditMode(); 
	    //reset edit mode for all rows
	 	table.cleanUpAfterSave();
	 	//create a new row and add cells 
	  	var tr = new JsmTr();
	  	var cellCountTr = table._headerRow;
	  	if (cellCountTr==null) {cellCountTr=table._rows[0];}	  	
	  	var cellCount = 1;
	  	for (cellCount;cellCount<=cellCountTr._cells.length;cellCount++) {
	  		tr.addCell(new JsmTd());
	  	}
	  	tr.setEditMode(true);
	  	table.addRow(tr);
	  	table.render();
	  	table.focusOnFirstWidget();	
		jsmOnAddRow(table, tr.idx);
	  } 	 
	  
	  /**
	 * Will be called by the after the the add row button has been clicked; define your own version of this function if needed
	 * @param {JsmTable} table The table object
	 * @param {int} rowIdx The index of the row
	 */   
	  function jsmOnAddRow(table, rowIdx) {
	  }   

/** A header action cell: Show only the header row */ 
	 jsmShowOnlyHeaderActionCell = new JsmActionCell("<img src='" + jsmUpImage + "' border='0'></img>").setTitle(jsmTitleShowOnlyHeader).setOnClick('_jsmShowOnlyHeader');   
	 jsmShowOnlyHeaderActionCell.init = function(table, rowIdx, columnIdx) {
	 	logger.debug("jsmShowOnlyHeaderActionCell.init(): " + rowIdx + " - " + columnIdx);
	 	if (!table.isShowOnlyHeader()) {
	 		table.getHeaderRow().getActionCell(columnIdx).setValue("<img src='" + jsmUpImage + "' border='0'></img>");
	  		table.getHeaderRow().getActionCell(columnIdx).setTitle(jsmTitleShowOnlyHeader); 	
	 	} else {
	  		table.getHeaderRow().getActionCell(columnIdx).setValue("<img src='" + jsmDownImage + "' border='0'></img>");
		  	table.getHeaderRow().getActionCell(columnIdx).setTitle(jsmTitleDisplayAllRows); 	
	 	}
	 } 
		 
	/**
	 * Will be called by the jsmShowOnlyHeaderActionTh
	 * @param {JsmTable} table The table object
	 * @param {int} rowIdx The index of the row
	 * @param {int} columnIdx The index of the column 
	 * @private
	 */
	  function _jsmShowOnlyHeader(table, rowIdx, columnIdx) {
	    table.setShowOnlyHeader(!table.isShowOnlyHeader());
	    table.render();
	  } 
	  
/** A header/footer action cell: Hide table */ 
	 jsmHideTableActionCell = new JsmActionCell("<img src='" + jsmHideImage + "' border='0'></img>").setTitle(jsmTitleHide).setOnClick('_jsmHideTable');   

	/**
	 * Will be called by the jsmHideTableActionCell
	 * @param {JsmTable} table The table object
	 * @param {int} rowIdx The index of the row
	 * @param {int} columnIdx The index of the column 
	 * @private
	 */
	  function _jsmHideTable(table, rowIdx, columnIdx) {
		var theContainer = document.getElementById(table.getContainerId());
	    theContainer.innerHTML = "<img id='jsmShowTable' src='" + jsmShowImage + "' border='0' title='" + jsmTitleShow + "' onclick='" + table.getVariableName() + ".render();'></img>";  	
	  }  		  	 
		 

/** A header/footer action cell: Goto first page */ 
	 jsmGotoFirstPageActionCell = new JsmActionCell("<img src='" + jsmFirstImage + "' border='0'></img>").setTitle(jsmTitleFirst).setOnClick('_jsmOnGotoFirstPage');   
	 
	 /**
	 * Will be called by the jsmGotoFirstPageActionCell
	 * @param {JsmTable} table The table object
	 * @param {int} rowIdx The index of the row
	 * @param {int} columnIdx The index of the column 
	 * @private
	 */
	  function _jsmOnGotoFirstPage(table, rowIdx, columnIdx) {
		logger.debug("_jsmOnGotoFirstPage: set current start row: 0");  
		table.setPageingCurrentStartRow(0);  
		table.render();	  
	  } 
	  	 

/** A header/footer action cell: Goto previous page */ 
	 jsmGotoPreviousPageActionCell = new JsmActionCell("<img src='" + jsmPreviousImage + "' border='0'></img>").setTitle(jsmTitlePrevious).setOnClick('_jsmOnGotoPreviousPage');   
	
	 /**
	 * Will be called by the jsmGotoPreviousPageActionCell
	 * @param {JsmTable} table The table object
	 * @param {int} rowIdx The index of the row
	 * @param {int} columnIdx The index of the column 
	 * @private
	 */
	  function _jsmOnGotoPreviousPage(table, rowIdx, columnIdx) {
		if (table.getPageingCurrentStartRow()>0) {	
		  	var newCurrentStartRow = table.getPageingCurrentStartRow() - table.getPageingMaxRows();
		  	if (newCurrentStartRow<0) {newCurrentStartRow=0};
		  	logger.debug("_jsmOnGotoPreviousPage: set current start row: " + newCurrentStartRow);  
		  	table.setPageingCurrentStartRow(newCurrentStartRow);
		  	table.render();
		}
	  } 
	  	 

/** A header/footer action cell: Goto next page */ 
 	jsmGotoNextPageActionCell = new JsmActionCell("<img src='" + jsmNextImage + "' border='0'></img>").setTitle(jsmTitleNext).setOnClick('_jsmOnGotoNextPage');   
	 	
	 /**
	 * Will be called by the jsmGotoNextPageActionCell
	 * @param {JsmTable} table The table object
	 * @param {int} rowIdx The index of the row
	 * @param {int} columnIdx The index of the column 
	 * @private
	 */
	  function _jsmOnGotoNextPage(table, rowIdx, columnIdx) {
	  	var maxStartRow = table.getFilteredRows().length - table.getPageingMaxRows();
	    if (table.getPageingCurrentStartRow() < maxStartRow) {	
		  	var newCurrentStartRow = table.getPageingCurrentStartRow() + table.getPageingMaxRows();
		  	if (newCurrentStartRow > maxStartRow) {newCurrentStartRow = maxStartRow;}
		  	logger.debug("_jsmOnGotoNextPage: set current start row: " + newCurrentStartRow);
			table.setPageingCurrentStartRow(newCurrentStartRow);
			table.render();	
		}
	  } 	

/** A header/footer action cell: Goto last page */ 
	 jsmGotoLastPageActionCell = new JsmActionCell("<img src='" + jsmLastImage + "' border='0'></img>").setTitle(jsmTitleLast).setOnClick('_jsmOnGotoLastPage');   
		 
	 /**
	 * Will be called by the jsmGotoLastPageActionCell
	 * @param {JsmTable} table The table object
	 * @param {int} rowIdx The index of the row
	 * @param {int} columnIdx The index of the column 
	 * @private
	 */
	  function _jsmOnGotoLastPage(table, rowIdx, columnIdx) {
		var newCurrentStartRow = table.getFilteredRows().length - table.getPageingMaxRows();	  
		logger.debug("_jsmOnGotoLastPage: set current start row: " + newCurrentStartRow);  
		table.setPageingCurrentStartRow(newCurrentStartRow);  
		table.render();	  
	  } 	 

/** A header/footer action cell: Shows the number of rows shown during pageing */ 	 
	 jsmPageCounter = new JsmActionCell("%{(jsmFilteredRowsCount==0?jsmFilteredRowsCount:(this.tr.table.getPageingCurrentStartRow()+1)) + '-' + ((this.tr.table.getPageingCurrentStartRow()+this.tr.table.getPageingMaxRows())>jsmFilteredRowsCount?jsmFilteredRowsCount:(this.tr.table.getPageingCurrentStartRow()+this.tr.table.getPageingMaxRows())) + '/' + jsmFilteredRowsCount}").setTitle(" ");   	 
	  

jsm

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