Subversion Repositories Applications.papyrus

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2150 mathias 1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2
        "http://www.w3.org/TR/html4/strict.dtd">
3
<html>
4
<head>
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";
11
 
12
		.oddRow { background-color: #f2f5f9; }
13
		.population { text-align: right; }
14
	</style>
15
 
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");
24
	</script>
25
</head>
26
<body class="tundra">
27
	<span dojoType="dojo.data.ItemFileReadStore"
28
		jsId="continentStore"
29
		url="../../../dijit/tests/_data/countries.json"></span>
30
	<span dojoType="dojox.data.FlickrStore" jsId="flickrStore"></span>
31
 
32
 
33
	<h1 class="testTitle">Dojox Data Demo Table</h1>
34
 
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>
40
		</thead>
41
		<tbody dojoAttachPoint="body">
42
			<tr dojoAttachPoint="row">
43
			</tr>
44
		</tbody>
45
 
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;
52
				tth.className = icn;
53
				dojo.connect(tth, "onclick", dojo.hitch(this, "onSort", idx));
54
				this.headRow.appendChild(tth);
55
 
56
				// and fill in the column cell in the template row
57
				this.row.appendChild(document.createElement("td"));
58
				this.row.lastChild.className = icn;
59
			}, this);
60
			this.runQuery();
61
		</script>
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).styles("background", "").styles("paddingRight", "");
67
			if(qs && qs[0].attribute == ca){
68
				qs[0].descending = !qs[0].descending;
69
			}else{
70
				this.query.sort = [{
71
					attribute: ca,
72
					descending: false
73
				}];
74
			}
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";
78
			this.runQuery();
79
		</script>
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");
86
			});
87
			this.store.fetch(this.query);
88
		</script>
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); }
95
				n.innerHTML = tv;
96
			}, this);
97
			this.body.appendChild(tr);
98
		</script>
99
	</table>
100
 
101
	<span dojoType="demo.Table" store="continentStore"
102
		query="{ query: { type: 'country' }, sort: [ { attribute: 'name', descending: true } ]  }"
103
		id="foo">
104
		<script type="dojo/method" event="preamble">
105
			this.columns = [
106
				{ name: "Name", attribute: "name" },
107
				{	name: 		"Population",
108
					attribute:	"population",
109
					className:	"population"
110
				}
111
			];
112
		</script>
113
	</span>
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">
119
			this.columns = [
120
				{	name: "", attribute: "imageUrlSmall",
121
					format: function(value, item, store){
122
						return (value.length) ? "<img src='"+value+"'>" : "";
123
					}
124
				},
125
				{ name: "Title", attribute: "title" }
126
			];
127
		</script>
128
	</span>
129
</body>
130
</html>