Subversion Repositories Applications.papyrus

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2150 mathias 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>dojox.Grid with Dojo.Data via binding</title>
6
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
7
	<style type="text/css">
8
		@import "../_grid/tundraGrid.css";
9
		@import "../../../dojo/resources/dojo.css";
10
		@import "../../../dijit/themes/tundra/tundra.css";
11
		@import "../../../dijit/tests/css/dijitTests.css";
12
 
13
		#grid, #grid2, #grid3 {
14
			width: 65em;
15
			height: 25em;
16
			padding: 1px;
17
		}
18
	</style>
19
	<script type="text/javascript" src="../../../dojo/dojo.js"
20
		djConfig="isDebug: true, debugAtAllCosts: false, parseOnLoad: true"></script>
21
	<script type="text/javascript">
22
		dojo.require("dojox.grid.Grid");
23
		dojo.require("dojox.grid._data.editors");
24
		dojo.require("dojox.grid._data.model");
25
		dojo.require("dojox.data.CsvStore");
26
		dojo.require("dojo.data.ItemFileWriteStore");
27
		dojo.require("dojo.parser");
28
	</script>
29
	<script type="text/javascript">
30
		function getRow(inRowIndex){
31
			return ' ' + inRowIndex;
32
		}
33
 
34
		var iEditor = dojox.grid.editors.Input;
35
		var layoutMovies = [
36
			// view 0
37
			{ type: 'dojox.GridRowView', width: '20px' },
38
			// view 1
39
			{ cells: [[{ name: "Row", get: getRow, width: 5}]], noscroll: true},
40
			// view 2
41
			{ cells: [[
42
				{ field: "Title", editor: iEditor, width: 'auto' },
43
				{ field: "Year",  editor: iEditor, width: 5 },
44
				{ field: "Producer", editor: iEditor, width: 20 }
45
			]]}
46
		];
47
 
48
		var layoutCountries = [
49
			// view 0
50
			{ type: 'dojox.GridRowView', width: '20px' },
51
			// view 1
52
			{ cells: [[{ name: "Row", get: getRow, width: 5}]], noscroll: true},
53
			// view 2
54
			{ cells: [[
55
				{ field: "name", name: "Name", width: 'auto' },
56
				{ field: "type", name: "Type", editor: iEditor, width: 'auto' },
57
			]]}
58
		];
59
	</script>
60
</head>
61
<body class="tundra">
62
	<h1>dojox.Grid using Dojo.Data stores via simple binding</h1>
63
	<!--
64
	<br>
65
	<span dojoType="dojox.data.CsvStore"
66
		jsId="csvStore" url="support/movies.csv">
67
	</span>
68
	<span dojoType="dojox.grid.data.DojoData"
69
		jsId="dataModel"
70
		store="csvStore"
71
		rowsPerPage="5"
72
		query="{ Title: '*' }"
73
		clientSort="true">
74
	</span>
75
	<div id="grid" dojoType="dojox.Grid" elasticView="2"
76
		model="dataModel" structure="layoutMovies">
77
	</div>
78
	-->
79
	<br>
80
	<h3>Update some of the types</h3>
81
	<button onclick="updateCountryTypes();">Go!</button>
82
	<script>
83
		function updateCountryTypes(){
84
			// get everything starting with "A"
85
			jsonStore.fetch({
86
				query: { name: "A*" },
87
				onComplete: function(items, result){
88
					// change 'em!
89
					dojo.forEach(items, function(item){
90
						jsonStore.setValue(item, "type", "thinger");
91
						// console.debug(item);
92
					});
93
				}
94
			});
95
		}
96
	</script>
97
 
98
	<span dojoType="dojo.data.ItemFileWriteStore"
99
		jsId="jsonStore" url="../../../dijit/tests/_data/countries.json">
100
	</span>
101
	<span dojoType="dojox.grid.data.DojoData"
102
		jsId="dataModel2"
103
		rowsPerPage="20"
104
		store="jsonStore"
105
		clientSort="true"
106
		query="{ name : '*' }">
107
	</span>
108
	<div id="grid2" dojoType="dojox.Grid" elasticView="2"
109
		model="dataModel2" structure="layoutCountries">
110
	</div>
111
 
112
	<div id="grid3" dojoType="dojox.Grid" elasticView="2"
113
		model="dataModel2" structure="layoutCountries">
114
	</div>
115
</body>
116
</html>