view war/scripts/sti/STITable.js @ 41:90b7bbc9962f default

Merged the bugfixes
author Sebastian Kruse <skruse@mpiwg-berlin.mpg.de>
date Thu, 06 Dec 2012 18:09:00 +0100
parents cf06b77a8bbd
children
line wrap: on
line source

/**
 * defines the table component of the Spatio Temporal Interface
 * @param {STICore} core the sti core component, the table component has to deal with
 * 
 * @constructor
 */
function STITable(core){

    this.core = core;
    this.baseRow;
    this.dynamicTables;
    this.tableColumns;
    
	this.initialize();
    
}

STITable.prototype = {

    /**
     * initializes the table component by creating a table with a single row, which cells will contain the tables of data sets
     */
    initialize: function(){
        this.dynamicTables = [];
        var baseTable = document.createElement("table");
        document.getElementById("dataTables").appendChild(baseTable);
        baseTable.cellSpacing = "20";
        this.baseRow = baseTable.insertRow(0);
        this.tableColumns = [];
        this.status = 0;
        document.getElementById("dataTables").onselectstart = function(){
            return false;
        };
    },
    
    /**
     * deletes all tables
     */
    deleteTables: function(){
        for (var i = this.tableColumns.length; i > 0; i--) {
            this.baseRow.removeChild(this.tableColumns[i-1]);
            delete this.tableColumns[i-1];
            delete this.dynamicTables[i-1];
			this.tableColumns.pop();
			this.dynamicTables.pop();
        }		
    },
    
    /**
     * initializes the tables for given datasets
     * @param {Array} objects an array of object-array, which contain all elements that are in the actual display set
     * @param {DataSet[]} dataSets all dataSets; needed for the header rows of the data tables
     */
    initTables: function(dataSets){
    
        this.deleteTables();

        for (var i = 0; i < dataSets.length; i++) {        
			var dynamicTable = new DynamicTable(this.core,dataSets[i],i);          
            var column = this.baseRow.insertCell(0);
            column.width = Math.floor(100 / dataSets.length) + '%';
            column.appendChild(dynamicTable.tableDiv);
            this.tableColumns.push(column);
			this.dynamicTables.push(dynamicTable);
        }
       
    },
    
    /**
     * updates each dynamic table
     */
    updateTables: function(){
        for (var i = 0; i < this.dynamicTables.length; i++){
			this.dynamicTables[i].update();
		}
    }
    
}