source: Dev/branches/rest-dojo-ui/client/dojox/grid/cells/tree.js @ 256

Last change on this file since 256 was 256, checked in by hendrikvanantwerpen, 13 years ago

Reworked project structure based on REST interaction and Dojo library. As
soon as this is stable, the old jQueryUI branch can be removed (it's
kept for reference).

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