1 if(!dojo._hasResource["dojox.grid._grid.layout"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2 dojo._hasResource["dojox.grid._grid.layout"] = true;
3 dojo.provide("dojox.grid._grid.layout");
4 dojo.require("dojox.grid._grid.cell");
6 dojo.declare("dojox.grid.layout", null, {
8 // Controls grid cell layout. Owned by grid and used internally.
9 constructor: function(inGrid){
12 // flat array of grid cells
14 // structured array of grid cells
19 setStructure: function(inStructure){
22 var s = this.structure = [];
23 for(var i=0, viewDef, rows; (viewDef=inStructure[i]); i++){
24 s.push(this.addViewDef(viewDef));
26 this.cellCount = this.cells.length;
28 addViewDef: function(inDef){
29 this._defaultCellProps = inDef.defaultCell || {};
30 return dojo.mixin({}, inDef, {rows: this.addRowsDef(inDef.rows || inDef.cells)});
32 addRowsDef: function(inDef){
34 for(var i=0, row; inDef && (row=inDef[i]); i++){
35 result.push(this.addRowDef(i, row));
39 addRowDef: function(inRowIndex, inDef){
41 for(var i=0, def, cell; (def=inDef[i]); i++){
42 cell = this.addCellDef(inRowIndex, i, def);
44 this.cells.push(cell);
48 addCellDef: function(inRowIndex, inCellIndex, inDef){
50 if(inDef.colSpan > 1){
52 }else if(!isNaN(inDef.width)){
53 w = inDef.width + "em";
55 w = inDef.width || this.defaultWidth;
57 // fieldIndex progresses linearly from the last indexed field
58 // FIXME: support generating fieldIndex based a text field name (probably in Grid)
59 var fieldIndex = inDef.field != undefined ? inDef.field : (inDef.get ? -1 : this.fieldIndex);
60 if((inDef.field != undefined) || !inDef.get){
61 this.fieldIndex = (inDef.field > -1 ? inDef.field : this.fieldIndex) + 1;
63 return new dojox.grid.cell(
64 dojo.mixin({}, this._defaultCellProps, inDef, {
67 layoutIndex: inCellIndex,
68 index: this.cells.length,
69 fieldIndex: fieldIndex,