/*
    Copyright (C) 2008  Ivo Toby, Internet Voor Ondernemers, www.i-v-o.nl / blog.i-v-o.nl 

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

 */
	var crudderView = Class.create({
		initialize:function(metaData, container, controller){
			this.instID = 'crudderTable.' + parseInt(Math.random()*1000000);
			this.metaData = metaData;
			this.container = container;
			this.controller = controller;
			this.page = 0;
			this.itemsPerPage = metaData.config.defaultItemsPerPage;
			// set table-values:
			this.pKey = metaData.table.pKey;
			this.table = metaData.table.name;
			this.rowCount = metaData.table.rowCount;
			
			this.fields = $H({});
			this.loadFields();
		},
		
		loadFields:function(){
			this.metaData.fields.each(
				(function(field){
					var obj = this.createFieldObject(field);
					this.fields.set(field.name, obj);
				}).bind(this)
			)
		},
		
		createFieldObject : function(field){
			var obj = new crudderField[field.metaType](field, '', this);
			return obj;
		}
		
	})
