Skip to content

Commit

Permalink
merge in latest updates
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuxw committed Jun 11, 2012
1 parent 277bbd3 commit 48c19af
Show file tree
Hide file tree
Showing 38 changed files with 474 additions and 349 deletions.
12 changes: 3 additions & 9 deletions core/Core.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ define([

_postCreate: function(){
var t = this,
d = t._deferStartup = new Deferred;
d = t._deferStartup = new Deferred();
t._preload();
t._load(d).then(hitch(t, 'onModulesLoaded'));
},
Expand All @@ -235,16 +235,10 @@ define([

setStore: function(store){
// summary:
// Change the store for grid.
// description:
// Since store defines the data model for grid, changing store is usually changing everything.
// Change the store for grid.
// store: dojo.data.*|dojox.data.*|dojo.store.*
// The new data store
var t = this;
t.store = store;
t._reset(t);
t._postCreate();
t._deferStartup.callback();
this.model.setStore(store);
},


Expand Down
2 changes: 1 addition & 1 deletion core/Row.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ define([
item = t.item(),
field, d;
if(s.setValue){
d = new Deferred;
d = new Deferred();
try{
for(field in rawData){
s.setValue(item, field, rawData[field]);
Expand Down
2 changes: 0 additions & 2 deletions core/_Module.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,6 @@ var isFunc = lang.isFunction,
var p = modClass.prototype;
return mods[p.name || p.declaredClass] = modClass;
};
//! means not string, should be 'eval'ed.
moduleBase._markupAttrs = ['id', 'name', 'field', 'width', 'dataType', '!formatter', '!decorator', '!sortable'];

return moduleBase;
});
4 changes: 4 additions & 0 deletions core/model/Model.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ define([
isId: function(id){
return id || id === 0;
},

setStore: function(store){
this._cache.setStore(store);
},

//Public-------------------------------------------------------------------

Expand Down
35 changes: 20 additions & 15 deletions core/model/cache/_Cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,26 @@ define([
// summary:
// Abstract base cache class, providing cache data structure and some common cache functions.
constructor: function(model, args){
var t = this;
t.setStore(args.store);
t.columns = args.columns;
t._mixinAPI('byIndex', 'byId', 'indexToId', 'idToIndex', 'size', 'treePath', 'hasChildren', 'keep', 'free');
},

destroy: function(){
this.inherited(arguments);
this.clear();
},

setStore: function(store){
var t = this,
c = 'connect',
s = t.store = args.store,
old = s.fetch;
t.columns = args.columns;
if(!old && s.notify){
old = store.fetch;
t.clear();
t.store = store;
if(!old && store.notify){
//The store implements the dojo.store.Observable API
t[c](s, 'notify', function(item, id){
t[c](store, 'notify', function(item, id){
if(item === undefined){
t._onDelete(id);
}else if(id === undefined){
Expand All @@ -33,17 +45,10 @@ define([
}
});
}else{
t[c](s, old ? "onSet" : "put", "_onSet");
t[c](s, old ? "onNew" : "add", "_onNew");
t[c](s, old ? "onDelete" : "remove", "_onDelete");
t[c](store, old ? "onSet" : "put", "_onSet");
t[c](store, old ? "onNew" : "add", "_onNew");
t[c](store, old ? "onDelete" : "remove", "_onDelete");
}
t.clear();
t._mixinAPI('byIndex', 'byId', 'indexToId', 'idToIndex', 'size', 'treePath', 'hasChildren', 'keep', 'free');
},

destroy: function(){
this.inherited(arguments);
this.clear();
},

//Public----------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions core/model/extensions/ClientFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ define([
this._mixinAPI('filter', 'hasFilter');
model.onFilterProgress = function(){};
this.connect(model, '_msg', '_receiveMsg');
this.connect(model, 'setStore', 'clear');
},

//Public---------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions core/model/extensions/Mark.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ define([
t._mixinAPI('getMark', 'getMarkedIds', 'markById', 'markByIndex', 'clearMark', 'treeMarkMode');
t.connect(model, '_msg', '_receiveMsg');
t.connect(model._cache, 'onLoadRow', '_onLoadRow');
t.connect(model, 'setStore', 'clear');
model.onMarkChange = function(){};
model._spTypes = {};
},
Expand Down
3 changes: 2 additions & 1 deletion modules/Bar.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
define([
"require",
"dojo/_base/kernel",
"dojo/_base/declare",
"dojo/_base/lang",
Expand All @@ -7,7 +8,7 @@ define([
"dojo/dom-construct",
"../core/_Module",
"../util"
], function(kernel, declare, lang, array, a11y, domConstruct, _Module, util){
], function(require, kernel, declare, lang, array, a11y, domConstruct, _Module, util){

kernel.experimental('gridx/modules/Bar');

Expand Down
34 changes: 21 additions & 13 deletions modules/Body.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ define([
}],
[g, 'setColumns', function(){
t.refresh();
}],
[g, 'setStore', function(){
t.refresh();
}]
);
m.when({}, function(){
Expand Down Expand Up @@ -114,16 +117,17 @@ define([

//Public-----------------------------------------------------------------------------
rowHoverEffect: true,
/*
* infoArgs: {
* rowId
* rowIndex
* visualIndex
* parentId
* colId
* colIndex
* }
*/

/*=====
infoArgs: {
rowId
rowIndex
visualIndex
parentId
colId
colIndex
},
=====*/

getRowNode: function(args){
// summary:
Expand Down Expand Up @@ -421,7 +425,7 @@ define([
onAfterRow: function(/* Row */){},
onAfterCell: function(){},
onRender: function(/*start, count*/){},
onUnrender: function(){},
onUnrender: function(/* id */){},
// onNew: function(/*id, index, rowCache*/){},
onDelete: function(/*id, index*/){},
onSet: function(/*id, index, rowCache*/){},
Expand Down Expand Up @@ -641,7 +645,8 @@ define([
pid = node[ga]('parentid'),
pids = {id: 1},
toDelete = [node],
rid, ids = [id];
rid, ids = [id],
vidx;
for(sn = node.nextSibling; sn && pids[sn[ga]('parentid')]; sn = sn.nextSibling){
rid = sn[ga]('rowid');
ids.push(rid);
Expand All @@ -652,9 +657,12 @@ define([
if(sn[ga]('parentid') == pid){
sn[sa]('rowindex', parseInt(sn[ga]('rowindex'), 10) - 1);
}
sn[sa]('visualindex', parseInt(sn[ga]('visualindex'), 10) - 1);
vidx = parseInt(sn[ga]('visualindex'), 10) - 1;
sn[sa]('visualindex', vidx);
domClass.toggle(sn, 'gridxRowOdd', vidx % 2);
++count;
}
t.renderCount -= toDelete.length;
array.forEach(toDelete, domConstruct.destroy);
array.forEach(ids, t.onUnrender, t);
if(t.autoChangeSize && t.rootStart === 0 && !pid){
Expand Down
6 changes: 2 additions & 4 deletions modules/CellWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ define([
}
});

_Module._markupAttrs.push('!widgetsInCell', '!setCellValue');

return declare(/*===== "gridx.modules.CellWidget", =====*/_Module, {
// summary:
// This module makes it possible to efficiently show widgets within a grid cell.
Expand Down Expand Up @@ -279,8 +277,8 @@ define([
_showDijit: function(cell){
var col = cell.column.def();
if(col.userDecorator || this._getSpecialCellDec(cell.row.id, col.id)){
cellWidget = this._prepareCellWidget(cell);
var cellNode = cell.node();
var cellWidget = this._prepareCellWidget(cell),
cellNode = cell.node();
cellNode.innerHTML = "";
cellWidget.placeAt(cellNode);
cellWidget.startup();
Expand Down
18 changes: 6 additions & 12 deletions modules/ColumnLock.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,9 @@ define([
this._updateScroller();
this.grid.hScroller && this.grid.hScroller._doScroll();
this.grid.header.onRender();
// this.grid.body.onRender();
},
_lockColumns: function(rowNode){
//summary:
// summary:
// Lock columns for one row
if(!this.count || this.count >= this.grid._columns.length){
this.count = 0;
Expand All @@ -149,11 +148,6 @@ define([
for(i = 0; i < this.count; i++){
dojo.style(r.cells[i], 'height', 'auto');
}
// var h = 0;
// array.forEach(r.cells, function(cell){
// var mh = dojo.contentBox(r.cells[r.cells.length - 1]).h;
// if(h < mh)h = mh;
// });

var h1 = dojo.contentBox(r.cells[r.cells.length - 1]).h,
h2 = dojo.marginBox(r.cells[r.cells.length - 1]).h;
Expand All @@ -175,33 +169,33 @@ define([
},

_updateHeader: function(){
//summary:
// summary:
// Update the header for column lock
var rowNode = query('.gridxHeaderRowInner', this.grid.headerNode)[0];
this._lockColumns(rowNode);
this._updateScroller();//used for column dnd to sync hscroller.
},

_updateBody: function(){
//summary:
// summary:
// Update the body for column lock
array.forEach(this.grid.bodyNode.childNodes, this._lockColumns, this);
},

_updateScroller: function(){
//summary:
// summary:
// Update h-scroller for column lock
if(this.grid.hScroller){this.grid.hScroller.refresh();}
},

_hackHScroller: function(){
//summary:
// summary:
// This method changes behavior of hscroller. It will scroll each row instead of the body node
// while some columns are locked.
var _this = this;
lang.mixin(this.grid.hScroller, {
_doScroll: function(){
//summary:
// summary:
// Sync the grid body with the scroller.

var scrollLeft = this.domNode.scrollLeft;
Expand Down
4 changes: 2 additions & 2 deletions modules/ColumnResizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ define([
// module name
name: 'columnResizer',

// required: ['hScroller'],
// required: ['hScroller'],

// minWidth: Integer
// min column width in px
Expand Down Expand Up @@ -206,7 +206,7 @@ define([
t._resizer = domConstruct.create('div', {
className: 'gridxColumnResizer'},
t.grid.domNode, 'last');
t.connect(t._resizer, 'mouseup', '_mouseup');
t.connect(t._resizer, 'mouseup', '_mouseup');
}
t._resizer.style.display = 'block';
t._updateResizerPosition(e);
Expand Down
4 changes: 3 additions & 1 deletion modules/ColumnWidth.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ define([
t.batchConnect(
[g, '_onResizeBegin', function(changeSize, ds){
ds.header = new Deferred();
if(!t.arg('autoResize')){
if(!t.arg('autoResize') && array.some(g._columns, function(col){
return !col.width || col.width == 'auto' || /%$/.test(col.width);
})){
t._adaptWidth();
}else{
var w = g.domNode.clientWidth - g.hLayout.lead - g.hLayout.tail;
Expand Down
19 changes: 9 additions & 10 deletions modules/Dod.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ define([
return declare(/*===== "gridx.modules.Dod", =====*/_Module, {
name: 'dod',
required: ['body'],
//useAnimation: Boolean
// useAnimation: Boolean
// Indicates whether to use animation (slide) when showing/hiding the detail part.
useAnimation: true,

//duration: Number
// duration: Number
// The time used to play the animation.
duration: 750,

defaultShow: false,
showExpando: true,

//autoClose: Boolean
// autoClose: Boolean
// Indicates whether the detail part should be closed automatically when another row's detail part is shown.
autoClose: false,
load: function(args, deferStartup){
Expand Down Expand Up @@ -58,13 +58,13 @@ define([
},

show: function(row){
//summary:
// summary:
// Show the detail part of a row, if this row has a detail part.
// Use animation (slide the detail part out) if useAnimation is true.
// Nothing happens if rowId is not valid or the row does not has a detail part.
//rowId: String
// rowId: String
// The ID of a row.
//return: dojo.Deferred.
// return: dojo.Deferred.
// A deferred object indicating when the detail is completely shown.
var _row = this._row(row);
if(_row.dodShown || _row.inAnim){return;}
Expand Down Expand Up @@ -106,13 +106,13 @@ define([
},

hide: function(row){
//summary:
// summary:
// Hide the detail part of a row, if this row has a detail part.
// Use animation (slide the detail part in) if useAnimation is true.
// Nothing happens if rowId is not valid or the row does not has a detail part.
//rowId: String
// rowId: String
// The ID of a row.
//return: dojo.Deferred.
// return: dojo.Deferred.
// A deferred object indicating when the detail is completely hidden.
var _row = this._row(row), g = this.grid;
if(!_row.dodShown || _row.inAnim){return;}
Expand All @@ -130,7 +130,6 @@ define([
}
}).play();
_row.defaultShow = false;
//html.style(_row.dodNode, 'display', 'none');
},

toggle: function(row){
Expand Down
Loading

0 comments on commit 48c19af

Please sign in to comment.