Debian Codegraph @

dojox/grid/tests/test_data_grid_setStore.html

raw symbols SCIP
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2 "http://www.w3.org/TR/html4/loose.dtd">
3 <html>
4 <head>
5 <title>Test DataGrid - setStore</title>
6 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
7 <style type="text/css">
8 @import "../../../dijit/themes/tundra/tundra.css";
9 @import "../../../dojo/resources/dojo.css";
10 @import "../../../dijit/tests/css/dijitTests.css";
11 @import "../resources/Grid.css";
12 @import "../resources/tundraGrid.css";
13
14 body {
15 font-size: 0.9em;
16 font-family: Geneva, Arial, Helvetica, sans-serif;
17 }
18 button {
19 margin: 20px;
20 }
21 .heading {
22 font-weight: bold;
23 padding-bottom: 0.25em;
24 }
25 .grid {
26 width: 65em;
27 padding: 1px;
28 }
29 </style>
30 <script type="text/javascript" src="../../../dojo/dojo.js"
31 data-dojo-config="isDebug:false, parseOnLoad: true"></script>
32 <script type="text/javascript">
33 dojo.require("dijit.dijit"); // optimize: load dijit layer
34 dojo.require("dojox.grid.DataGrid");
35 dojo.require("dojo.data.ItemFileWriteStore");
36 dojo.require("dojo.parser");
37
38 dojo.declare("dojox.grid.SlowFileWriteStore", dojo.data.ItemFileWriteStore, {
39 _fetchItems: function( /*Object*/ keywordArgs,
40 /*Function*/ findCallback,
41 /*Function*/ errorCallback){
42 setTimeout(dojo.hitch(this, function(){
43 dojo.data.ItemFileWriteStore.prototype._fetchItems.call(this, keywordArgs, findCallback, errorCallback);
44 }), 10000);
45 }
46 });
47
48 function createStore(type)
49 {
50 // Create a new datastore and use the Grid's setStore() function to change it.
51 var newStore, args = {}, grid = dijit.byId("grid");
52 if(type=="slow"){
53 // Slow Loading store
54 args.url = "../../../dijit/tests/_data/countries.json";
55 newStore = new dojox.grid.SlowFileWriteStore(args);
56 grid.setStore(newStore, { name: '*' });
57 }else if(type=="empty"){
58 // Empty result set -- set the Grid's query to something with no results
59 args.url = "../../../dijit/tests/_data/countries.json";
60 newStore = new dojo.data.ItemFileWriteStore(args);
61 grid.setStore(newStore, { name: 'nonexist' });
62 }else if(type=="error"){
63 // Error result -- set the url to a file that doesn't exist
64 args.url = "../../../dijit/tests/_data/countries-no.json";
65 newStore = new dojo.data.ItemFileWriteStore(args);
66 grid.setStore(newStore);
67 }else{//type=="standard"
68 args.url = "../../../dijit/tests/_data/countries.json";
69 newStore = new dojo.data.ItemFileWriteStore(args);
70 grid.setStore(newStore);
71 }
72 }
73 </script>
74 <script type="text/javascript" src="support/test_data.js"></script>
75 </head>
76 <body class="tundra">
77 <h1>dojox.grid.DataGrid using setStore() to change datastores.</h1>
78 <p>
79 This page demonstrates the ability to change datastores using the
80 DataGrid's setStore() function. Click on any of the buttons above
81 the Grid to set a new store and refresh the Grid display.
82 </p>
83 <p>
84 <button onclick="createStore('standard');">Standard Store</button>
85 <button onclick="createStore('slow');">Slow Loading Store</button>
86 <button onclick="createStore('empty');">Empty Store</button>
87 <button onclick="createStore('error');">Error Store</button>
88 </p>
89 <span dojoType="dojo.data.ItemFileWriteStore"
90 data-dojo-id="jsonStore" url="../../../dijit/tests/_data/countries.json">
91 </span>
92 <div class="heading">Grid Test</div>
93 <table dojoType="dojox.grid.DataGrid"
94 data-dojo-id="grid" id="grid" class="grid" autoHeight="15" noDataMessage="Sorry, there is no data available."
95 store="jsonStore" query="{ name: '*' }" rowsPerPage="20" rowSelector="20px">
96 <thead>
97 <tr>
98 <th field="name" width="300px">Country/Continent Name</th>
99 <th field="type" width="auto">Type</th>
100 </tr>
101 </thead>
102 </table>
103 </body>
104 </html>