summaryrefslogtreecommitdiff
path: root/includes/js/dojox/grid/tests/test_change_structure.html
blob: 4ecfa71c6faa147634478991a7027a2342362791 (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
115
116
117
118
119
120
121
122
123
124
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<title>dojox.Grid Change Structure Example</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
	<style type="text/css">
		@import "../_grid/Grid.css";
		body {
			font-size: 0.9em;
			font-family: Geneva, Arial, Helvetica, sans-serif;
		}
		.heading {
			font-weight: bold;
			padding-bottom: 0.25em;
		}
				
		#grid { 
			border: 1px solid #333;
			width: 48em;
			height: 30em;
		}
		
		#grid .dojoxGrid-cell {
			text-align: center;
		}
	</style>
	<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug:false, parseOnLoad: true"></script>
	<script type="text/javascript">
		dojo.require("dojox.grid.Grid");
		dojo.require("dojo.parser");
	</script>
	<script type="text/javascript">

		// get can return data for a cell of the grid
		function get(inRowIndex) {
			return [this.index, inRowIndex].join(', ');
		}

		// grid structure
		// a grid view is a group of columns
		
		// a special view providing selection feedback
		var rowBar = {type: 'dojox.GridRowView', width: '20px' };
		
		// a view without scrollbars
		var view0 = {
			noscroll: true,
			cells: [[
				{name: 'Alpha', value: '<input name="" type="checkbox" value="0">'},
				{name: 'Beta', get: get, width: 4.5}
		]]};
		
		var view1 = {
			cells: [[
				{name: 'Apple', value: '<button>Apple</button>'},
				{name: 'Banana', get: get},
				{name: 'Beans', value: 'Happy to be grid!'},
				{name: 'Kiwi', get: get},
				{name: 'Orange', value: '<img src="images/flatScreen.gif" height="48" width="48">'},
				{name: 'Pear', get: get},
				{name: 'Tomato', width: 20, value: '<input name="" type="file">'},
		]]};
		
		var view2 = {
			noscroll: true,
			cells: [
				[
					{name: 'Alpha', value: '<input name="" type="checkbox" value="0">', rowSpan: 2},
					{name: 'Beta', get: get, width: 4.5}
				], [
					{name: 'Gamma', get: get}
				],
				[
					{name: 'Epsilon', value: '<button>Epsilon</button>', colSpan: 2}
				]
			]	
		}
		
		var view3 = {
			cells: [
				[	
					{name: 'Apple', value: '<button>Apple</button>', rowSpan: 3},
					{name: 'Banana', get: get, width: 20},
					{name: 'Kiwi', get: get, width: 20},
					{name: 'Pear', get: get, width: 20},
				],
				[
					{name: 'Beans', value: 'Happy to be grid!'},
					{name: 'Orange', value: '<img src="images/flatScreen.gif" height="48" width="48">'},
					{name: 'Tomato', value: '<input name="" type="file">'}
				], [
					{name: 'Zuchini', value: '<span style="letter-spacing: 10em;">wide</span>', colSpan: 3}
				]
			]};
		
		
		// a grid structure is an array of views.
		// By default the middle view will be 'elastic', sized to fit the remaining space left by other views
		// grid.elasticView can also be manually set
		var structure = [ rowBar, view0, view1 ];
		var structure2 = [ rowBar, view2, view3 ];
		
		
		var l2 = false;
		toggleStructure = function() {
			l2 = !l2;
			grid.scrollToRow(0);
			grid.setStructure(l2 ? structure2 : structure);
		}
		
		dojo.addOnLoad(function() {
			window["grid"] = dijit.byId("grid");
		});
</script>
</head>
<body>
<div class="heading">dojox.VirtualGrid Change Structure Example</div>
<p>
	<button onclick="toggleStructure()">Change Structure</button>
</p>	
<div id="grid" dojoType="dojox.VirtualGrid" structure="structure" rowCount="100000" elasticView="2"></div>

</body>
</html>