Click here to Skip to main content
15,893,508 members
Articles / Web Development / ASP.NET

Monorail Hands-On

Rate me:
Please Sign up or sign in to vote.
4.78/5 (15 votes)
19 Feb 2008CPOL9 min read 71.3K   1.1K   40  
In this article, I will present a sample application using the Monorail framework and provide the basic concepts of the design pattern known as MVC.
/*
 * Ext JS Library 1.0.1
 * Copyright(c) 2006-2007, Ext JS, LLC.
 * licensing@extjs.com
 * 
 * http://www.extjs.com/license
 */

Ext.grid.ColumnModel=function(_1){Ext.grid.ColumnModel.superclass.constructor.call(this);this.config=_1;this.lookup={};for(var i=0,_3=_1.length;i<_3;i++){if(typeof _1[i].dataIndex=="undefined"){_1[i].dataIndex=i;}if(typeof _1[i].renderer=="string"){_1[i].renderer=Ext.util.Format[_1[i].renderer];}if(typeof _1[i].id=="undefined"){_1[i].id=i;}this.lookup[_1[i].id]=_1[i];}this.defaultWidth=100;this.defaultSortable=false;this.addEvents({"widthchange":true,"headerchange":true,"hiddenchange":true,"columnmoved":true,"columnlockchange":true});Ext.grid.ColumnModel.superclass.constructor.call(this);};Ext.extend(Ext.grid.ColumnModel,Ext.util.Observable,{getColumnId:function(_4){return this.config[_4].id;},getColumnById:function(id){return this.lookup[id];},getIndexById:function(id){for(var i=0,_8=this.config.length;i<_8;i++){if(this.config[i].id==id){return i;}}return -1;},moveColumn:function(_9,_a){var c=this.config[_9];this.config.splice(_9,1);this.config.splice(_a,0,c);this.dataMap=null;this.fireEvent("columnmoved",this,_9,_a);},isLocked:function(_c){return this.config[_c].locked===true;},setLocked:function(_d,_e,_f){if(this.isLocked(_d)==_e){return;}this.config[_d].locked=_e;if(!_f){this.fireEvent("columnlockchange",this,_d,_e);}},getTotalLockedWidth:function(){var _10=0;for(var i=0;i<this.config.length;i++){if(this.isLocked(i)&&!this.isHidden(i)){this.totalWidth+=this.getColumnWidth(i);}}return _10;},getLockedCount:function(){for(var i=0,len=this.config.length;i<len;i++){if(!this.isLocked(i)){return i;}}},getColumnCount:function(_14){if(_14==true){var c=0;for(var i=0,len=this.config.length;i<len;i++){if(!this.isHidden(i)){c++;}}return c;}return this.config.length;},isSortable:function(col){if(typeof this.config[col].sortable=="undefined"){return this.defaultSortable;}return this.config[col].sortable;},getRenderer:function(col){if(!this.config[col].renderer){return Ext.grid.ColumnModel.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,_1e,_1f){this.config[col].width=_1e;this.totalWidth=null;if(!_1f){this.fireEvent("widthchange",this,col,_1e);}},getTotalWidth:function(_20){if(!this.totalWidth){this.totalWidth=0;for(var i=0,len=this.config.length;i<len;i++){if(_20||!this.isHidden(i)){this.totalWidth+=this.getColumnWidth(i);}}}return this.totalWidth;},getColumnHeader:function(col){return this.config[col].header;},setColumnHeader:function(col,_25){this.config[col].header=_25;this.fireEvent("headerchange",this,col,_25);},getColumnTooltip:function(col){return this.config[col].tooltip;},setColumnTooltip:function(col,_28){this.config[col].tooltip=_28;},getDataIndex:function(col){return this.config[col].dataIndex;},setDataIndex:function(col,_2b){this.config[col].dataIndex=_2b;},findColumnIndex:function(_2c){var c=this.config;for(var i=0,len=c.length;i<len;i++){if(c[i].dataIndex==_2c){return i;}}return -1;},isCellEditable:function(_30,_31){return (this.config[_30].editable||(typeof this.config[_30].editable=="undefined"&&this.config[_30].editor))?true:false;},getCellEditor:function(_32,_33){return this.config[_32].editor;},setEditable:function(col,_35){this.config[col].editable=_35;},isHidden:function(_36){return this.config[_36].hidden;},isFixed:function(_37){return this.config[_37].fixed;},isResizable:function(_38){return this.config[_38].resizable!==false;},setHidden:function(_39,_3a){this.config[_39].hidden=_3a;this.totalWidth=null;this.fireEvent("hiddenchange",this,_39,_3a);},setEditor:function(col,_3c){this.config[col].editor=_3c;}});Ext.grid.ColumnModel.defaultRenderer=function(_3d){if(typeof _3d=="string"&&_3d.length<1){return "&#160;";}return _3d;};Ext.grid.DefaultColumnModel=Ext.grid.ColumnModel;

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Instructor / Trainer Alura Cursos Online
Brazil Brazil

Comments and Discussions