summaryrefslogtreecommitdiff
path: root/includes/js/dojox/grid/tests/test_sizing_100rows.html
blob: 4ea1aa3c305761f6ced27ebd3e7c1e52e677e76e (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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<title>dojox.Grid Sizing Example</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
	<style type="text/css">
		@import "../../../dojo/resources/dojo.css";
		@import "../_grid/tundraGrid.css";
		
		body {
			font-size: 0.9em;
			font-family: Geneva, Arial, Helvetica, sans-serif;
		}
		.heading {
			font-weight: bold;
			padding-bottom: 0.25em;
		}
		
		#container {
			width: 400px;
			height: 200px;
			border: 4px double #333; 
		}
				
		#grid { 
			border: 1px solid #333;
		}
	</style>
	<script type="text/javascript" src="../../../dojo/dojo.js" 
		djConfig="isDebug: true, parseOnLoad: true"></script>
	<script type="text/javascript">
		/*dojo.require("dojox.grid.Grid");
		dojo.require("dojo.parser");*/
	</script>
	<!-- Debugging -->
	<script type="text/javascript" src="../_grid/lib.js"></script>
	<script type="text/javascript" src="../_grid/drag.js"></script>
	<script type="text/javascript" src="../_grid/scroller.js"></script>
	<script type="text/javascript" src="../_grid/builder.js"></script>
	<script type="text/javascript" src="../_grid/cell.js"></script>
	<script type="text/javascript" src="../_grid/layout.js"></script>
	<script type="text/javascript" src="../_grid/rows.js"></script>
	<script type="text/javascript" src="../_grid/focus.js"></script>
	<script type="text/javascript" src="../_grid/selection.js"></script>
	<script type="text/javascript" src="../_grid/edit.js"></script>
	<script type="text/javascript" src="../_grid/view.js"></script>
	<script type="text/javascript" src="../_grid/views.js"></script>
	<script type="text/javascript" src="../_grid/rowbar.js"></script>
	<script type="text/javascript" src="../_grid/publicEvents.js"></script>
	<script type="text/javascript" src="../VirtualGrid.js"></script>
	<script type="text/javascript" src="../_data/fields.js"></script>
	<script type="text/javascript" src="../_data/model.js"></script>
	<script type="text/javascript" src="../_data/editors.js"></script>
	<script type="text/javascript" src="../Grid.js"></script>
	<script type="text/javascript" src="support/test_data.js"></script>
	<script type="text/javascript">
		// 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 leftView = {
			noscroll: true,
			cells: [[
				{name: 'Column 0'},
				{name: 'Column 1'}
		]]};
		
		var middleView = {
			cells: [[
				{name: 'Column 2'},
				{name: 'Column 3'},
				{name: 'Column 4'},
				{name: 'Column 5'},
				{name: 'Column 6'},
		]]};
		
		// a grid structure is an array of views.
		var structure = [ rowBar, leftView, middleView];
		
		// get can return data for each cell of the grid
		function get(inRowIndex) {
			return [this.index, inRowIndex].join(', ');
		}
		
		function resizeInfo() {
			setTimeout(function() {
				dojo.byId('gridWidth').value = grid.domNode.clientWidth;
				dojo.byId('gridHeight').value = grid.domNode.clientHeight;
			}, 1);
		}
		
		function resizeGrid() {
			grid.autoHeight = false;
			grid.autoWidth = false;
			var
				w = Number(dojo.byId('gridWidth').value),
				h = Number(dojo.byId('gridHeight').value);
			
			dojo.contentBox(grid.domNode, {w: w, h: h});
			grid.update();
		}
		
		function fitWidth() {
			grid.autoWidth = true;
			grid.autoHeight = false;
			grid.update();
		}
		
		function fitHeight() {
			grid.autoWidth = false;
			grid.autoHeight = true;
			grid.update();
		}
		
		function fitBoth() {
			grid.autoWidth = true;
			grid.autoHeight = true;
			grid.update();
		}
		
		function sizeDefault() {
			grid.autoWidth = false;
			grid.autoHeight = false;
			grid.domNode.style.width = '';
			grid.domNode.style.height = 0;
			grid.update();
		}
		
		dojo.addOnLoad(function() {
			window["grid"] = dijit.byId("grid");
			dojo.byId('gridWidth').value = 500;
			dojo.byId('gridHeight').value = 200;
			dojo.connect(grid, 'update', resizeInfo);
			resizeGrid();
			window["grid1"] = dijit.byId("grid1");
		});
		
	
</script>
</head>
<body class="tundra">
<div class="heading">dojox.Grid Sizing Test</div>
	Grid width: <input id="gridWidth" type="text">&nbsp; 
	and height: <input id="gridHeight" type="text">&nbsp;
	<button onclick="resizeGrid()">Resize Grid</button><br><br>
	<button onclick="fitWidth()">Fit Data Width</button>&nbsp;
	<button onclick="fitHeight()">Fit Data Height</button>&nbsp;
	<button onclick="fitBoth()">Fit Data Width & Height</button>
	<button onclick="sizeDefault()">DefaultSize</button><br><br>
	<div id="grid" dojoType="dojox.Grid" autoWidth="true" autoHeight="true" model="model" structure="structure" elasticView="2"></div>
	
	<p>Grid fits to a sized container by default:</p>
	<div id="container">
		<div id="grid1" dojoType="dojox.VirtualGrid" get="get" structure="structure" rowCount="10" elasticView="2"></div>
	</div>

	<p> Grid is essentially hidden (height of zero) when parent container is unsized 
		(nothing, including the header, should be displayed):</p>
	<div id="unsizedContainer">
		<div id="grid2" dojoType="dojox.VirtualGrid" get="get" structure="structure" rowCount="10" elasticView="2"></div>
	</div>

	<p> Grid is autoHeight and autoWidth via markup</p>
		<div id="grid3" dojoType="dojox.VirtualGrid" autoWidth="true" autoHeight="true" get="get" structure="structure" rowCount="100" elasticView="2"></div>
</body>
</html>