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 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2
<html>
3
<head>
4
	<title>Test dojox.Grid Expand Rows</title>
5
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
6
	<style type="text/css">
7
		@import "../_grid/Grid.css";
8
		body {
9
			font-size: 0.9em;
10
			font-family: Geneva, Arial, Helvetica, sans-serif;
11
		}
12
		.heading {
13
			font-weight: bold;
14
			padding-bottom: 0.25em;
15
		}
16
 
17
		.bigHello {
18
			height: 110px;
19
			line-height: 110px;
20
			text-align: center;
21
			font-weight: bold;
22
			font-size: 30px;
23
		}
24
 
25
		#grid {
26
			border: 1px solid #333;
27
			height: 30em;
28
		}
29
	</style>
30
	<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug:false, parseOnLoad: true"></script>
31
	<script type="text/javascript">
32
		dojo.require("dojox.grid.Grid");
33
		dojo.require("dojox.grid._data.model");
34
		dojo.require("dojo.parser");
35
	</script>
36
	<script type="text/javascript">
37
		// grid structure
38
		// a grid view is a group of columns
39
 
40
		// a special view providing selection feedback
41
		var rowBar = {type: 'dojox.GridRowView', width: '20px' };
42
 
43
		// inRow is an array of subRows. we hide the summary subRow except for every nth row
44
		function onBeforeRow(inDataIndex, inRow) {
45
			inRow[1].hidden = (!this.grid || !this.grid.expandedRows || !this.grid.expandedRows[inDataIndex]);
46
		}
47
 
48
		var view = {
49
			onBeforeRow: onBeforeRow,
50
			cells: [
51
				[
52
					{ name: 'Whatever', width: 4.5, get: getCheck, styles: 'text-align: center;' },
53
					{name: 'Column 0'},
54
					{name: 'Column 1'},
55
					{name: 'Column 2'},
56
					{name: 'Column 3'},
57
					{name: 'Column 4'}
58
				],
59
				[ { name: 'Detail', colSpan: 6, get: getDetail } ]
60
			]
61
		};
62
 
63
		// a grid structure is an array of views.
64
		var structure = [ rowBar, view ];
65
 
66
		// get can return data for each cell of the grid
67
		function get(inRowIndex) {
68
			return [this.index, inRowIndex].join(', ');
69
		}
70
 
71
		function getDetail(inRowIndex) {
72
			if (this.grid.expandedRows[inRowIndex]) {
73
				var n = (inRowIndex % 2);
74
				switch (n) {
75
					case 0:
76
						return 'Hello World!';
77
					default:
78
						return '<div class="bigHello">Hello World!</div>';
79
				}
80
			} else
81
				return '';
82
		}
83
 
84
		function toggle(inIndex, inShow) {
85
			grid.expandedRows[inIndex] = inShow;
86
			grid.updateRow(inIndex);
87
		}
88
 
89
		function getCheck(inRowIndex) {
90
			if (!this.grid.expandedRows)
91
				this.grid.expandedRows = [ ];
92
			var image = (this.grid.expandedRows[inRowIndex] ? 'open.gif' : 'closed.gif');
93
			var show = (this.grid.expandedRows[inRowIndex] ? 'false' : 'true')
94
			return '<img src="images/' + image + '" onclick="toggle(' + inRowIndex + ', ' + show + ')" height="11" width="11">';
95
		}
96
 
97
	dojo.addOnLoad(function() {
98
		window["grid"] = dijit.byId("grid");
99
	});
100
</script>
101
</head>
102
<body>
103
<div class="heading">dojox.Grid Expand Row Example</div>
104
 
105
<div id="grid" dojoType="dojox.VirtualGrid" get="get" structure="structure" rowCount="100000" autoWidth="true"></div>
106
 
107
</body>
108
</html>