source: Dev/trunk/src/client/dojox/grid/tests/test_treegrid_loading.html

Last change on this file was 483, checked in by hendrikvanantwerpen, 11 years ago

Added Dojo 1.9.3 release.

File size: 4.1 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2<html>
3<head>
4        <title>dojox.grid.TreeGrid Tests</title>
5        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
6        <style type="text/css">
7                @import "../../../dojo/resources/dojo.css";
8                @import "../resources/Grid.css";
9                @import "../resources/tundraGrid.css";
10                .grid {
11                        width: 70em;
12                        height: 15em;
13                }
14        </style>
15        <script type="text/javascript" src="../../../dojo/dojo.js"
16                data-dojo-config="isDebug:false, parseOnLoad: false"></script>
17        <script type="text/javascript">
18                dojo.require("dojox.grid.TreeGrid");
19                dojo.require("dojox.data.JsonRestStore");
20                dojo.require("dojo.parser");
21               
22                var data_part = {};
23                var data_full = {};
24                store = null;
25
26                var dataService = function(query, opts){
27                        var d = new dojo.Deferred();
28                        if(typeof query != "object"){
29                                setTimeout(function(){
30                                        d.callback(data_full[query]);
31                                }, 5000);
32                                return d;
33                        }else{
34                                var data = [];
35                                for(var i in data_part){
36                                        data.push(data_part[i]);
37                                }
38                                d.callback(data);
39                                return d;
40                        }
41                }
42                dataService.servicePath = "/";
43
44                dojo.addOnLoad(function(){
45                        dojox.rpc._sync = false;
46                        dojo.xhrGet({
47                                url: "support/gamedata.json",
48                                handleAs: "json",
49                                sync: true
50                        }).addCallback(function(res){
51                                var p2 = res.items[1];
52                                p2.seasns.push({
53                                        games: [],
54                                        id: 60,
55                                        label: "Season 3",
56                                        numGames: 0,
57                                        numQtrs: 0,
58                                        totAst: 0,
59                                        totPts: 0,
60                                        totReb: 0,
61                                        totTP: 0
62                                });
63                                for(var i = 0, l = p2.seasns.length; i<l; i++){
64                                        var item = p2.seasns[i];
65                                        data_full[item.id] = dojo.mixin({}, item);
66                                        delete item['games'];
67                                        item['$ref'] = item.id;
68                                        data_part[item.id] = dojo.mixin({}, item);
69                                }
70                        });
71                        store = new dojox.data.JsonRestStore({
72                                service: dataService,
73                                cacheByDefault: true
74                        });
75                        dojo.parser.parse();
76                        dojo.connect(window, "onresize", grid, "resize");
77                });
78
79                function formatTime(value, rowIdx){
80                        var hrs = Math.floor(value / 60) + "";
81                        var mins = (value % 60) + "";
82                        while (hrs.length < 2){
83                                hrs = "0" + hrs;
84                        }
85                        while (mins.length < 2){
86                                mins = "0" + mins;
87                        }
88                        return hrs + ":" + mins;
89                }
90               
91                function summaryFormatter(value, rowIdx, cell, sing, plur){
92                        var str;
93                        if(rowIdx >= 0){
94                                return value;
95                        }
96                        if(rowIdx == -1){
97                                str = "Total (${numItems} ${displayName}):";
98                        }else{
99                                str = "${numItems} ${displayName}";
100                        }
101                        return dojo.string.substitute(str, {numItems: value,
102                                                displayName: (value == 1) ? sing : plur});                     
103                }
104                function quarterSummary(value, rowIdx){
105                        return summaryFormatter(value, rowIdx, this, "Quarter", "Quarters");
106                }
107                function gameSummary(value, rowIdx){
108                        return summaryFormatter(value, rowIdx, this, "Game", "Games");
109                }
110                function seasonSummary(value, rowIdx){
111                        return summaryFormatter(value, rowIdx, this, "Season", "Seasons");
112                }
113        </script>
114</head>
115<body class="tundra">
116        <h1 class="testTitle">Test: dojox.tests.grid.TreeGrid</h1>
117        <h4 class="testSubtitle">dojox.grid.TreeGrid Large 4-Level - calculated totals and openAtLevels</h4>
118        <table dojoType="dojox.grid.TreeGrid" class="grid" style="height: 45em;width: 100%;"
119                store="store" rowsPerPage="20" data-dojo-id="grid" rowSelector="true" openAtLevels="false,true,3">
120                        <thead>
121                                <tr>
122                                        <th field="label" relWidth="2" formatter="seasonSummary">Players</th>
123                                        <th field="games" itemAggregates="numGames">
124                                                <table>
125                                                        <thead>
126                                                                <tr>
127                                                                        <th field="label" relWidth="2" formatter="gameSummary">Game</th>
128                                                                        <th field="qtrs" itemAggregates="numQtrs,totPts,totReb,totAst,totTP">
129                                                                                <table>
130                                                                                        <thead>
131                                                                                                <tr>
132                                                                                                        <th field="label" relWidth="2" formatter="quarterSummary">Quarter</th>
133                                                                                                        <th field="pts" relWidth="1">Points</th>
134                                                                                                        <th field="reb" relWidth="1">Rebounds</th>
135                                                                                                        <th field="ast" relWidth="1">Assists</th>
136                                                                                                        <th field="tp" relWidth="1" formatter="formatTime">Time Played</th>
137                                                                                                </tr>
138                                                                                        </thead>
139                                                                                </table>
140                                                                        </th>
141                                                                </tr>
142                                                        </thead>
143                                                </table>
144                                        </th>
145                                </tr>
146                        </thead>
147        </table>
148        Text After
149</body>
150</html>
151
Note: See TracBrowser for help on using the repository browser.