]> git.pond.sub.org Git - eow/blob - static/dojo-release-1.1.1/dojox/data/tests/ml/test_HtmlTableStore_declaratively.html
add Dojo 1.1.1
[eow] / static / dojo-release-1.1.1 / dojox / data / tests / ml / test_HtmlTableStore_declaratively.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2 <html>
3 <head>
4 <title>Dojox HtmlDataStore Widget</title>
5 <style>
6         @import "../../../../dijit/themes/tundra/tundra.css";
7         @import "../../../../dojo/resources/dojo.css";
8         @import "../../../../dijit/tests/css/dijitTests.css";
9 </style>
10 <script type="text/javascript">
11         djConfig = {
12                 isDebug: true,
13                 parseOnLoad: true
14         };
15 </script>
16 <script type="text/javascript" src="../../../../dojo/dojo.js"></script>
17 <!--
18 <script language="JavaScript" type="text/javascript">
19         dojo.require("doh.runner");
20         function registerTests() {
21                 doh.register("t", 
22                         [
23                                 function testTableLoaded(t){
24                                         t.assertTrue(tableStore !== null);
25                                         t.assertTrue(tableStore !== undefined);
26                                 }
27                         ]
28                 );
29                 doh.run();
30         };
31         dojo.addOnLoad(registerTests);
32 </script>
33 -->
34
35 <script language="JavaScript" type="text/javascript">
36         dojo.require("dojo.parser");
37         dojo.require("dojox.data.HtmlTableStore");
38         dojo.require("dijit.Tree");
39         
40         function init() {
41                 var table = tableStore;
42                 
43                 function testComplete(items, request){
44                         console.debug("Completed!");
45
46                         var attributes = null;
47                         for(var i = 0; i < items.length; i++){
48                                 attributes = table.getAttributes(items[i]);
49                                 for(var j=0; j < attributes.length; j++){
50                                         console.debug("attribute: [" + attributes[j] + "] have value: " + table.getValue(items[i], attributes[j]));
51                                 }
52                         }
53                         
54                 }
55                 table.fetch({query:{X:1}, onComplete: testComplete});
56                 table.fetch({query:{X:2}, onComplete: testComplete});
57                 table.fetch({query:{X:3}, onComplete: testComplete}); 
58                 table.fetch({query:{X:4}, onComplete: testComplete}); 
59                 table.fetch({query:{X:5}, onComplete: testComplete}); // Should be empty
60         }
61         dojo.addOnLoad(init);
62 </script>
63
64 </head>
65 <body class="tundra">
66         <h1>Dojox HtmlDataStore Widget</h1>
67         <hr/>
68         <br/>
69         <br/>
70
71         <!-- Instantiate the HtmlTableStore and bind it to global name tableStore -->
72         <div dojoType="dojox.data.HtmlTableStore" tableId="tableExample" jsId="tableStore"></div>
73
74         <!-- The table to link into with the HtmlTableStore-->
75         <table id="tableExample">
76                 <thead>
77                         <tr>
78                                 <th>X</th>
79                                 <th>Y</th>
80                                 <th>A</th>
81                                 <th>B</th>
82                         </tr>
83                 </thead>
84                 <tbody>
85                         <tr id="test">
86                                 <td>2</td>
87                                 <td>3</td>
88                                 <td></td>
89                                 <td>8</td>
90                         </tr>
91                         <tr>
92                                 <td>1</td>
93                                 <td>3</td>
94                                 <td>5</td>
95                                 <td>7</td>
96                         </tr>
97                         <tr>
98                                 <td>4</td>
99                                 <td>9</td>
100                                 <td>22</td>
101                                 <td>777</td>
102                         </tr>
103                         <tr>
104                                 <td>3231</td>
105                                 <td>3</td>
106                                 <td>535</td>
107                                 <td>747</td>
108                         </tr>
109
110                 </tbody>
111         </table>
112
113         <br/>
114         <br/>
115         <blockquote>
116                 <b>Table Rows: <br/><i>(Just to show that the tree can determine that the tableStore works like a store).<br/>Should have three branches, where the row had attr Y value of 3.</i></b>
117                 <div dojoType="dijit.Tree" id="tree" store="tableStore" query="{Y:3}" label="Test tree"></div>
118         </blockquote>
119 </body>
120 </html>