Skip to content

Commit

Permalink
merge with latest changes
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuxw committed May 6, 2012
1 parent 665e09b commit 19f5ea9
Show file tree
Hide file tree
Showing 36 changed files with 1,232 additions and 660 deletions.
9 changes: 7 additions & 2 deletions Grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ define([
"dojo/dom-geometry",
"dojo/_base/query",
"dijit/_WidgetBase",
"dijit/_FocusMixin",
"dijit/_TemplatedMixin",
"dojo/text!./templates/Grid.html",
"./core/Core",
Expand All @@ -17,13 +18,15 @@ define([
"./modules/VScroller",
"./modules/HScroller",
"./modules/ColumnWidth"
], function(declare, array, lang, domClass, domGeometry, query, _Widget, _TemplatedMixin, template,
], function(declare, array, lang, domClass, domGeometry, query,
_WidgetBase, _FocusMixin, _TemplatedMixin, template,
Core, _Module, Header, Body, VLayout, HLayout, VScroller, HScroller, ColumnWidth){

var forEach = array.forEach,
dummyFunc = function(){},

Grid = declare('gridx.Grid', [_Widget, _TemplatedMixin, Core], {

Grid = declare('gridx.Grid', [_WidgetBase, _TemplatedMixin, _FocusMixin, Core], {
// summary:
// Gridx is a highly extensible widget providing grid/table functionalities.
// description:
Expand All @@ -36,6 +39,7 @@ define([
// not sufficient enough, please refer to the following link for latest API docs:
// http://evanhw.github.com/gridx/doc/gridx.html


templateString: template,

coreModules: [
Expand Down Expand Up @@ -89,6 +93,7 @@ define([
this.inherited(arguments);
},


resize: function(changeSize){
// summary:
// Resize the grid using given width and height.
Expand Down
5 changes: 5 additions & 0 deletions core/Cell.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ define([
"dojo/_base/declare"
], function(declare){


return declare(/*===== "gridx.core.Cell", =====*/[], {
// summary:
// Represents a cell of a grid
Expand All @@ -27,6 +28,7 @@ define([
model: null,
=====*/


constructor: function(grid, row, column){
var t=this;
t.grid = grid;
Expand All @@ -35,6 +37,7 @@ define([
t.column = column;
},


data: function(){
// summary:
// Get the grid data of this cell.
Expand All @@ -46,6 +49,7 @@ define([
return this.model.byId(this.row.id).data[this.column.id]; //String|Number
},


rawData: function(){
// summary:
// Get the store data of this cell.
Expand All @@ -57,6 +61,7 @@ define([
return f && t.model.byId(t.row.id).rawData[f]; //anything
},


setRawData: function(rawData){
// summary:
// Set new raw data to this cell.
Expand Down
9 changes: 9 additions & 0 deletions core/Column.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ define([
"dojo/_base/declare"
], function(declare){


return declare(/*===== "gridx.core.Column", =====*/[], {
// summary:
// Represents a column of a grid
Expand All @@ -23,12 +24,15 @@ define([
model: null,
=====*/



constructor: function(grid, id){
this.grid = grid;
this.model = grid.model;
this.id = id;
},


index: function(){
// summary:
// Get the index of this column
Expand All @@ -38,6 +42,7 @@ define([
return c ? c.index : -1; //Integer
},


cell: function(row, isId){
// summary:
// Get a cell object in this column
Expand All @@ -48,6 +53,7 @@ define([
return this.grid.cell(row, this, isId); //gridx.core.Cell|null
},


name: function(){
// summary:
// Get the name of this column.
Expand All @@ -59,6 +65,7 @@ define([
return this.grid._columnsById[this.id].name || ''; //String
},


setName: function(name){
// summary:
// Set the name of this column
Expand All @@ -70,6 +77,7 @@ define([
return this; //gridx.core.Column
},


field: function(){
// summary:
// Get the store field of this column
Expand All @@ -81,6 +89,7 @@ define([
return this.grid._columnsById[this.id].field || null; //String
},


getWidth: function(){
// summary:
// Get the width of this column
Expand Down
35 changes: 24 additions & 11 deletions core/Core.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,25 +79,27 @@ define([
var mods = [],
coreModCount = coreMods && coreMods.length || 0;
forEach(args.modules, function(m, i){
if(isFunc(m)){
mods.push({
if(isFunc(m) || isString(m)){
m = {
moduleClass: m
});
}else if(!m){
console.error(["The ", (i + 1 - coreModCount),
"-th declared module can NOT be found, please require it before using it"].join(''));
}else{
};
}
if(m){
var mc = m.moduleClass;
if(isString(mc)){
mc = require(mc);
try{
mc = m.moduleClass = require(mc);
}catch(e){
console.error(e);
}
}
if(isFunc(mc)){
mods.push(m);
}else{
console.error(["The ", (i + 1 - coreModCount),
"-th declared module has NO moduleClass, please provide it"].join(''));
return;
}
}
console.error(["The ", (i + 1 - coreModCount),
"-th declared module can NOT be found, please require it before using it"].join(''));
});
args.modules = mods;
return args;
Expand Down Expand Up @@ -193,6 +195,8 @@ define([
// so that the whole grid can be as flexible as possible while still convenient enough for
// web page developers.



_reset: function(args){
//Reset the grid data model completely. Also used in initialization.
var t = this;
Expand Down Expand Up @@ -227,6 +231,7 @@ define([
// callback
},


setStore: function(store){
// summary:
// Change the store for grid.
Expand All @@ -241,6 +246,7 @@ define([
t._deferStartup.callback();
},


setColumns: function(columns){
// summary:
// Change all the column definitions for grid.
Expand All @@ -255,6 +261,7 @@ define([
}
},


row: function(row, isId){
// summary:
// Get a row object by ID or index.
Expand All @@ -278,6 +285,7 @@ define([
return null; //null
},


column: function(column, isId){
// summary:
// Get a column object by ID or index
Expand Down Expand Up @@ -305,6 +313,7 @@ define([
return null; //null
},


cell: function(row, column, isId){
// summary:
// Get a cell object
Expand All @@ -330,6 +339,7 @@ define([
return null; //null
},


columnCount: function(){
// summary:
// Get the number of columns
Expand All @@ -338,6 +348,7 @@ define([
return this._columns.length; //Integer
},


rowCount: function(parentId){
// summary:
// Get the number of rows.
Expand All @@ -350,6 +361,7 @@ define([
return this.model.size(parentId); //Integer
},


columns: function(start, count){
// summary:
// Get a range of columns, from index 'start' to index 'start + count'.
Expand All @@ -364,6 +376,7 @@ define([
return this._arr(this._columns.length, 'column', start, count); //gridx.core.Column[]
},


rows: function(start, count){
// summary:
// Get a range of rows, from index 'start' to index 'start + count'.
Expand Down
9 changes: 9 additions & 0 deletions core/Row.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ define([
"dojo/_base/Deferred"
], function(declare, lang, Deferred){


return declare(/*===== "gridx.core.Row", =====*/[], {
// summary:
// Represents a row of a grid
Expand All @@ -25,12 +26,15 @@ define([
model: null,
=====*/



constructor: function(grid, id){
this.grid = grid;
this.model = grid.model;
this.id = id;
},


index: function(){
// summary:
// Get the index of this row
Expand All @@ -39,6 +43,7 @@ define([
return this.model.idToIndex(this.id); //Integer
},


cell: function(column, isId){
// summary:
// Get a cell object in this row
Expand All @@ -51,6 +56,7 @@ define([
return this.grid.cell(this, column, isId); //gridx.core.Cell|null
},


data: function(){
// summary:
// Get the grid data in this row.
Expand All @@ -62,6 +68,7 @@ define([
return this.model.byId(this.id).data; //Object
},


rawData: function(){
// summary:
// Get the store data in this row.
Expand All @@ -73,6 +80,7 @@ define([
return this.model.byId(this.id).rawData; //Object
},


item: function(){
// summary:
// Get the store item of this row
Expand All @@ -84,6 +92,7 @@ define([
return this.model.byId(this.id).item; //Object
},


setRawData: function(rawData){
// summary:
// Set new raw data of this row into the store
Expand Down
2 changes: 2 additions & 0 deletions core/_Module.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ define([
var isFunc = lang.isFunction,
c = 'connect', //To reduce code size


moduleBase = declare(/*===== "gridx.core._Module", =====*/[], {
/*=====
// name: String
Expand Down Expand Up @@ -95,6 +96,7 @@ var isFunc = lang.isFunction,
loaded: null,
=====*/


constructor: function(grid, args){
var t = this;
t.grid = grid;
Expand Down
4 changes: 4 additions & 0 deletions core/model/Model.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ define([
var isArrayLike = lang.isArrayLike,
isString = lang.isString;


return declare(/*===== "gridx.core.model.Model", =====*/[], {
// summary:
// This class handles all of the data logic in grid.
Expand All @@ -21,6 +22,7 @@ define([
// An instance of this class can be regarded as a stand-alone logic grid providing consistent data processing
// functionalities. This class can even be instanticated alone without any grid UI.


constructor: function(args){
var t = this,
c = 'connect',
Expand Down Expand Up @@ -139,6 +141,7 @@ define([
},
=====*/


when: function(args, callback, scope){
// summary:
// Call this method to make sure all the pending data operations are executed and
Expand Down Expand Up @@ -183,6 +186,7 @@ define([
return this._exec(); //dojo.Deferred
},


scan: function(args, callback){
// summary:
// Go through all the rows in several batches from start to end (or according to given args),
Expand Down
Loading

0 comments on commit 19f5ea9

Please sign in to comment.