/*
 * YUI Extensions 0.33 RC2
 * Copyright(c) 2006, Jack Slocum.
 */


YAHOO.ext.grid.DefaultColumnModel=function(config){YAHOO.ext.grid.DefaultColumnModel.superclass.constructor.call(this);this.config=config;this.defaultWidth=100;this.defaultSortable=false;};YAHOO.extendX(YAHOO.ext.grid.DefaultColumnModel,YAHOO.ext.grid.AbstractColumnModel,{getColumnCount:function(){return this.config.length;},isSortable:function(col){if(typeof this.config[col].sortable=='undefined'){return this.defaultSortable;}
return this.config[col].sortable;},getSortType:function(col){if(!this.dataMap){var map=[];for(var i=0,len=this.config.length;i<len;i++){map[this.getDataIndex(i)]=i;}
this.dataMap=map;}
col=this.dataMap[col];if(!this.config[col].sortType){return YAHOO.ext.grid.DefaultColumnModel.sortTypes.none;}
return this.config[col].sortType;},setSortType:function(col,fn){this.config[col].sortType=fn;},getRenderer:function(col){if(!this.config[col].renderer){return YAHOO.ext.grid.DefaultColumnModel.defaultRenderer;}
return this.config[col].renderer;},setRenderer:function(col,fn){this.config[col].renderer=fn;},getColumnWidth:function(col){return this.config[col].width||this.defaultWidth;},setColumnWidth:function(col,width,suppressEvent){this.config[col].width=width;this.totalWidth=null;if(!suppressEvent){this.onWidthChange.fireDirect(this,col,width);}},getTotalWidth:function(includeHidden){if(!this.totalWidth){this.totalWidth=0;for(var i=0;i<this.config.length;i++){if(includeHidden||!this.isHidden(i)){this.totalWidth+=this.getColumnWidth(i);}}}
return this.totalWidth;},getColumnHeader:function(col){return this.config[col].header;},setColumnHeader:function(col,header){this.config[col].header=header;this.onHeaderChange.fireDirect(this,col,header);},getDataIndex:function(col){if(typeof this.config[col].dataIndex!='number'){return col;}
return this.config[col].dataIndex;},setDataIndex:function(col,dataIndex){this.config[col].dataIndex=dataIndex;},isCellEditable:function(colIndex,rowIndex){return this.config[colIndex].editable||(typeof this.config[colIndex].editable=='undefined'&&this.config[colIndex].editor);},getCellEditor:function(colIndex,rowIndex){return this.config[colIndex].editor;},setEditable:function(col,editable){this.config[col].editable=editable;},isHidden:function(colIndex){return this.config[colIndex].hidden;},isFixed:function(colIndex){return this.config[colIndex].fixed;},isResizable:function(colIndex){return this.config[colIndex].resizable!==false;},setHidden:function(colIndex,hidden){this.config[colIndex].hidden=hidden;this.totalWidth=null;this.fireHiddenChange(colIndex,hidden);},setEditor:function(col,editor){this.config[col].editor=editor;}});YAHOO.ext.grid.DefaultColumnModel.sortTypes={none:function(s){return s;},asUCString:function(s){return String(s).toUpperCase();},asDate:function(s){if(s instanceof Date){return s.getTime();}
return Date.parse(String(s));},asFloat:function(s){var val=parseFloat(String(s).replace(/,/g,''));if(isNaN(val))val=0;return val;},asInt:function(s){var val=parseInt(String(s).replace(/,/g,''));if(isNaN(val))val=0;return val;}};YAHOO.ext.grid.DefaultColumnModel.defaultRenderer=function(value){if(typeof value=='string'&&value.length<1){return'&#160;';}
return value;}