Debian Codegraph @

dojox/data/demos/demo_QueryReadStore_grid.html

raw symbols SCIP
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 QueryReadStore+grid Demo</title>
5 <style type="text/css">
6 @import "../../../dijit/themes/tundra/tundra.css";
7 @import "../../../dojo/resources/dojo.css";
8 @import "../../../dijit/tests/css/dijitTests.css";
9 /* BE SURE TO NEVER FORGET IMPORTING THE GRID's CSS, or you will wonder why the
10 grid looks so strange (or even think that it doesnt work) */
11 @import "../../../dojox/grid/resources/tundraGrid.css";
12 </style>
13
14 <script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug:true, parseOnLoad: true, useCommentedJson: true"></script>
15 <script type="text/javascript">
16 dojo.require("dojox.grid.DataGrid");
17 dojo.require("dojox.data.QueryReadStore");
18 dojo.require("dojo.parser"); // scan page for widgets and instantiate them
19 var gridLayout = [
20 new dojox.grid.cells.RowIndex({ name: "row #", width: 5, styles: "text-align: right;" }),
21 {
22 name: "id",
23 field: "id",
24 styles: "text-align:right;",
25 width:5
26 },
27 {
28 name: "Name",
29 field: "name",
30 width:20
31 //formatter: rs.chunk.adminUser.grid.formatUser
32 },
33 {
34 name: "Capital",
35 field: "capital",
36 width:20
37 //formatter: rs.chunk.adminUser.grid.formatUser
38 },
39 {
40 name: "Label",
41 width:20,
42 //styles: "text-align:right;",
43 field: "label"
44 //formatter: phpr.grid.formatDate
45 },
46 {
47 name: "Abbrev.",
48 width:5,
49 //styles: "text-align:right;",
50 field: "abbreviation"
51 //formatter: phpr.grid.formatDate
52 }
53 ];
54 // Connect the store AFTER the page is loaded, since we can only access
55 // the widget then, since it will be created just before dojo.addOnLoad() is called.
56 var store = null;
57 dojo.addOnLoad(function() {
58 store = new dojox.data.QueryReadStore({
59 url:"../tests/stores/QueryReadStore.php",
60 requestMethod:"post"
61 });
62 grid1.setStore(store);
63 grid1.setStructure(gridLayout);
64 });
65
66 var lastSearchValue = "";
67 function doSearch(el) {
68 if (el.value!=lastSearchValue) {
69 lastSearchValue = el.value;
70 grid1.filter({name:el.value});
71 grid2.filter({name:el.value});
72 }
73 }
74 </script>
75 </head>
76 <body class="tundra">
77
78 <h1 class="testTitle">Dojox QueryReadStore + Grid demo - paging, sortable and filterable all server-side</h1>
79
80 <h2>The grid is in HTML, store, etc. are JS, sorting is added by extending the model class</h2>
81 <b>Capabilities:</b> load data from server, show data, paging (30 rows at a time), sort, filter<br />
82 You can see that data are loaded upon demand by scrolling down in the grid below line #30,
83 open FireBug and you see a server request being issued, to retreive another 30 rows/items.<br />
84 <br /><br />
85 <input type="text" onkeyup="doSearch(this)" />
86 <div id="grid1" jsid="grid1" dojoType="dojox.grid.DataGrid" query="{ name: '*' }" rowsPerPage="30" style="height:300px; width:800px;"></div>
87
88 <h2>The store and grid are "generated" and connected in HTML, filtering is done via JS</h2>
89 This store is by default sorted descending by name (not as the one above, which is ascending).
90 <div dojoType="dojox.data.QueryReadStore"
91 jsId="store2"
92 url="../tests/stores/QueryReadStore.php"
93 requestMethod="post"></div>
94 <!--<div dojoType="dojox.grid._data.DojoData"
95 jsId="model2"
96 store="store2"
97 sortFields="[{attribute: 'capital', descending: true}]"
98 rowsPerPage="30"></div>-->
99 <div dojoType="dojox.grid.DataGrid"
100 id="grid2" jsid="grid2"
101 store="store2"
102 query="{ name: '*' }"
103 rowsPerPage="30"
104 structure="gridLayout"
105 style="height:300px; width:800px;"></div>
106
107
108
109 </body>
110 </html>