[483] | 1 | define([ |
---|
| 2 | "dojo/_base/kernel", |
---|
| 3 | "../../main", |
---|
| 4 | "dojo/_base/lang", |
---|
| 5 | "../cells" |
---|
| 6 | ], function(dojo, dojox, lang){ |
---|
| 7 | |
---|
| 8 | dojox.grid.cells.TreeCell = { |
---|
| 9 | formatAggregate: function(inItem, level, inRowIndexes){ |
---|
| 10 | var f, g=this.grid, i=g.edit.info, |
---|
| 11 | d=g.aggregator ? g.aggregator.getForCell(this, level, inItem, level === this.level ? "cnt" : this.parentCell.aggregate) : (this.value || this.defaultValue); |
---|
| 12 | var ret = this._defaultFormat(d, [d, level - this.level, inRowIndexes, this]); |
---|
| 13 | var dir = this.textDir || this.grid.textDir; |
---|
| 14 | if(dir && this._enforceTextDirWithUcc){ |
---|
| 15 | ret = this._enforceTextDirWithUcc(dir, ret); |
---|
| 16 | } |
---|
| 17 | return ret; |
---|
| 18 | }, |
---|
| 19 | formatIndexes: function(inRowIndexes, inItem){ |
---|
| 20 | var f, g=this.grid, i=g.edit.info, |
---|
| 21 | d=this.get ? this.get(inRowIndexes[0], inItem, inRowIndexes) : (this.value || this.defaultValue); |
---|
| 22 | if(this.editable && (this.alwaysEditing || (i.rowIndex==inRowIndexes[0] && i.cell==this))){ |
---|
| 23 | return this.formatEditing(d, inRowIndexes[0], inRowIndexes); |
---|
| 24 | }else{ |
---|
| 25 | var ret = this._defaultFormat(d, [d, inRowIndexes[0], inRowIndexes, this]); |
---|
| 26 | var dir = this.textDir || this.grid.textDir; |
---|
| 27 | if(dir && this._enforceTextDirWithUcc){ |
---|
| 28 | ret = this._enforceTextDirWithUcc(dir, ret); |
---|
| 29 | } |
---|
| 30 | return ret; |
---|
| 31 | } |
---|
| 32 | }, |
---|
| 33 | getOpenState: function(itemId){ |
---|
| 34 | var grid = this.grid, store = grid.store, itm = null; |
---|
| 35 | if(store.isItem(itemId)){ |
---|
| 36 | itm = itemId; |
---|
| 37 | itemId = store.getIdentity(itemId); |
---|
| 38 | } |
---|
| 39 | if(!this.openStates){ this.openStates = {}; } |
---|
| 40 | if(typeof itemId != "string" || !(itemId in this.openStates)){ |
---|
| 41 | this.openStates[itemId] = grid.getDefaultOpenState(this, itm); |
---|
| 42 | } |
---|
| 43 | return this.openStates[itemId]; |
---|
| 44 | }, |
---|
| 45 | formatAtLevel: function(inRowIndexes, inItem, level, summaryRow, toggleClass, cellClasses){ |
---|
| 46 | if(!lang.isArray(inRowIndexes)){ |
---|
| 47 | inRowIndexes = [inRowIndexes]; |
---|
| 48 | } |
---|
| 49 | var result = ""; |
---|
| 50 | if(level > this.level || (level === this.level && summaryRow)){ |
---|
| 51 | cellClasses.push("dojoxGridSpacerCell"); |
---|
| 52 | if(level === this.level){ |
---|
| 53 | cellClasses.push("dojoxGridTotalCell"); |
---|
| 54 | } |
---|
| 55 | result = '<span></span>'; |
---|
| 56 | }else if(level < this.level){ |
---|
| 57 | cellClasses.push("dojoxGridSummaryCell"); |
---|
| 58 | result = '<span class="dojoxGridSummarySpan">' + this.formatAggregate(inItem, level, inRowIndexes) + '</span>'; |
---|
| 59 | }else{ |
---|
| 60 | var ret = ""; |
---|
| 61 | if(this.isCollapsable){ |
---|
| 62 | var store = this.grid.store, id = ""; |
---|
| 63 | if(store.isItem(inItem)){ |
---|
| 64 | id = store.getIdentity(inItem); |
---|
| 65 | } |
---|
| 66 | cellClasses.push("dojoxGridExpandoCell"); |
---|
| 67 | ret = '<span ' + dojo._scopeName + 'Type="dojox.grid._Expando" level="' + level + '" class="dojoxGridExpando"' + |
---|
| 68 | '" toggleClass="' + toggleClass + '" itemId="' + id + '" cellIdx="' + this.index + '"></span>'; |
---|
| 69 | } |
---|
| 70 | result = ret + this.formatIndexes(inRowIndexes, inItem); |
---|
| 71 | } |
---|
| 72 | |
---|
| 73 | if(this.grid.focus.cell && this.index == this.grid.focus.cell.index && |
---|
| 74 | inRowIndexes.join('/') == this.grid.focus.rowIndex){ |
---|
| 75 | cellClasses.push(this.grid.focus.focusClass); |
---|
| 76 | } |
---|
| 77 | |
---|
| 78 | return result; |
---|
| 79 | } |
---|
| 80 | }; |
---|
| 81 | |
---|
| 82 | return dojox.grid.cells.TreeCell; |
---|
| 83 | |
---|
| 84 | }); |
---|