1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2 "http://www.w3.org/TR/html4/strict.dtd">
5 <title>Dojo Visual Loader Test</title>
6 <style type="text/css">
7 @import "../../../dojo/resources/dojo.css";
8 @import "../../../dijit/themes/tundra/tundra.css";
9 @import "../../../dijit/themes/dijit.css";
10 @import "../../../dijit/tests/css/dijitTests.css";
12 .oddRow { background-color: #f2f5f9; }
13 .population { text-align: right; }
16 <script type="text/javascript" src="../../../dojo/dojo.js"
17 djConfig="isDebug: false, parseOnLoad: true"></script>
18 <script type="text/javascript">
19 dojo.require("dijit.dijit");
20 dojo.require("dojo.parser");
21 dojo.require("dijit.Declaration");
22 dojo.require("dojo.data.ItemFileReadStore");
23 dojo.require("dojox.data.FlickrStore");
27 <span dojoType="dojo.data.ItemFileReadStore"
29 url="../../../dijit/tests/_data/countries.json"></span>
30 <span dojoType="dojox.data.FlickrStore" jsId="flickrStore"></span>
33 <h1 class="testTitle">Dojox Data Demo Table</h1>
35 <table dojoType="dijit.Declaration"
36 widgetClass="demo.Table" class="dojoTabular"
37 defaults="{ store: null, query: { query: { name: '*' } }, columns: [ { name: 'Name', attribute: 'name' } ] }">
38 <thead dojoAttachPoint="head">
39 <tr dojoAttachPoint="headRow"></tr>
41 <tbody dojoAttachPoint="body">
42 <tr dojoAttachPoint="row">
46 <script type="dojo/method">
47 dojo.forEach(this.columns, function(item, idx){
48 var icn = item.className||"";
49 // add a header for each column
50 var tth = document.createElement("th");
51 tth.innerHTML = item.name;
53 dojo.connect(tth, "onclick", dojo.hitch(this, "onSort", idx));
54 this.headRow.appendChild(tth);
56 // and fill in the column cell in the template row
57 this.row.appendChild(document.createElement("td"));
58 this.row.lastChild.className = icn;
62 <script type="dojo/method" event="onSort" args="index">
63 var ca = this.columns[index].attribute;
64 var qs = this.query.sort;
65 // clobber an existing sort arrow
66 dojo.query("> th", this.headRow).style("background", "").style("paddingRight", "");
67 if(qs && qs[0].attribute == ca){
68 qs[0].descending = !qs[0].descending;
75 var th = dojo.query("> th", this.headRow)[index];
76 th.style.paddingRight = "16px"; // space for the sort arrow
77 th.style.background = "url(\""+dojo.moduleUrl("dijit", "themes/tundra/images/arrow"+(this.query.sort[0].descending ? "Up" : "Down")+((dojo.isIE == 6) ? ".gif" : ".png")) + "\") no-repeat 98% 4px";
80 <script type="dojo/method" event="runQuery">
81 this.query.onBegin = dojo.hitch(this, function(){ dojo.query("tr", this.body).orphan(); });
82 this.query.onItem = dojo.hitch(this, "onItem");
83 this.query.onComplete = dojo.hitch(this, function(){
84 dojo.query("tr:nth-child(odd)", this.body).addClass("oddRow");
85 dojo.query("tr:nth-child(even)", this.body).removeClass("oddRow");
87 this.store.fetch(this.query);
89 <script type="dojo/method" event="onItem" args="item">
90 var tr = this.row.cloneNode(true);
91 dojo.query("td", tr).forEach(function(n, i, a){
92 var tc = this.columns[i];
93 var tv = this.store.getValue(item, tc.attribute)||"";
94 if(tc.format){ tv = tc.format(tv, item, this.store); }
97 this.body.appendChild(tr);
101 <span dojoType="demo.Table" store="continentStore"
102 query="{ query: { type: 'country' }, sort: [ { attribute: 'name', descending: true } ] }"
104 <script type="dojo/method" event="preamble">
106 { name: "Name", attribute: "name" },
107 { name: "Population",
108 attribute: "population",
109 className: "population"
114 <span dojoType="demo.Table" store="continentStore"
115 query="{ query: { name: 'A*' } }"></span>
116 <span dojoType="demo.Table" store="flickrStore"
117 query="{ query: { tags: '3dny' } }">
118 <script type="dojo/method" event="preamble">
120 { name: "", attribute: "imageUrlSmall",
121 format: function(value, item, store){
122 return (value.length) ? "<img src='"+value+"'>" : "";
125 { name: "Title", attribute: "title" }