aboutsummaryrefslogtreecommitdiff
path: root/includes/js/dojox/grid/tests/test_dojo_data_notification.html
blob: f44c987a61b6be93e1c439e0ac096a443ff31d5c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
	"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<title>dojox.Grid with Dojo.Data via binding</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
	<style type="text/css">
		@import "../_grid/tundraGrid.css";
		@import "../../../dojo/resources/dojo.css";
		@import "../../../dijit/themes/tundra/tundra.css";
		@import "../../../dijit/tests/css/dijitTests.css";
		
		#grid, #grid2, #grid3 {
			width: 65em;
			height: 25em;
			padding: 1px;
		}
	</style>
	<script type="text/javascript" src="../../../dojo/dojo.js" 
		djConfig="isDebug: true, debugAtAllCosts: false, parseOnLoad: true"></script>
	<script type="text/javascript">
		dojo.require("dojox.grid.Grid");
		dojo.require("dojox.data.CsvStore");
		dojo.require("dojo.data.ItemFileWriteStore");
		dojo.require("dojo.parser");
	</script>
	<script type="text/javascript">
		function getRow(inRowIndex){
			return ' ' + inRowIndex;
		}

		var iEditor = dojox.grid.editors.Input;
		var layoutMovies = [
			// view 0
			{ type: 'dojox.GridRowView', width: '20px' },
			// view 1
			{ cells: [[{ name: "Row", get: getRow, width: 5}]], noscroll: true},
			// view 2
			{ cells: [[
				{ field: "Title", editor: iEditor, width: 'auto' },
				{ field: "Year",  editor: iEditor, width: 5 },
				{ field: "Producer", editor: iEditor, width: 20 }
			]]}
		];

		var layoutCountries = [
			// view 0
			{ type: 'dojox.GridRowView', width: '20px' },
			// view 1
			{ cells: [[{ name: "Row", get: getRow, width: 5}]], noscroll: true},
			// view 2
			{ cells: [[
				{ field: "name", name: "Name", width: 'auto' },
				{ field: "type", name: "Type", editor: iEditor, width: 'auto' },
			]]}
		];
	</script>
</head>
<body class="tundra">
	<h1>dojox.Grid using Dojo.Data stores via simple binding</h1>
	<!--
	<br>
	<span dojoType="dojox.data.CsvStore" 
		jsId="csvStore" url="support/movies.csv">
	</span>
	<span dojoType="dojox.grid.data.DojoData" 
		jsId="dataModel"
		store="csvStore"
		rowsPerPage="5"
		query="{ Title: '*' }"
		clientSort="true">
	</span>
	<div id="grid" dojoType="dojox.Grid" elasticView="2" 
		model="dataModel" structure="layoutMovies">
	</div>
	-->
	<br>
	<h3>Update some of the types</h3>
	<button onclick="updateCountryTypes();">Go!</button>
	<script>
		function updateCountryTypes(){
			// get everything starting with "A"
			jsonStore.fetch({
				query: { name: "A*" },
				onComplete: function(items, result){
					// change 'em!
					dojo.forEach(items, function(item){
						jsonStore.setValue(item, "type", "thinger");
						// console.debug(item);
					});
				}
			});
		}
	</script>

	<span dojoType="dojo.data.ItemFileWriteStore" 
		jsId="jsonStore" url="../../../dijit/tests/_data/countries.json">
	</span>
	<span dojoType="dojox.grid.data.DojoData" 
		jsId="dataModel2" 
		rowsPerPage="20"
		store="jsonStore" 
		clientSort="true"
		query="{ name : '*' }">
	</span>
	<div id="grid2" dojoType="dojox.Grid" elasticView="2" 
		model="dataModel2" structure="layoutCountries">
	</div>

	<div id="grid3" dojoType="dojox.Grid" elasticView="2" 
		model="dataModel2" structure="layoutCountries">
	</div>
</body>
</html>