aboutsummaryrefslogtreecommitdiff
path: root/includes/js/dojox/grid/tests/test_styling.html
blob: 5671f50ad6e585946b87388138f10a21030538f9 (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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<title>dojox.Grid Styling Test</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: 45em;
			height: 30em;
		}
		
		#grid .dojoxGrid-row {
			border: none;
		}
		
		#grid .dojoxGrid-row-table {
			border-collapse: collapse;
		}
		
		#grid .dojoxGrid-cell {
			border: none;
			padding: 10px;
		}
		
		.selectedRow .dojoxGrid-cell {
			background-color: #003366;
			color: white;
		}
		
		.specialRow .dojoxGrid-cell {
			background-color: dimgray;
		}
		
		.selectedRow.specialRow .dojoxGrid-cell {
			text-decoration: line-through;
			/* duplicate selection background-color so has precendence over specialRow background-color */
			background-color: #003366;
		}
		
		/* in the yellow column, assign specific decoration for special rows that are selected */
		.selectedRow.specialRow .yellowColumnData {
			text-decoration: line-through underline;
		}
		
		.yellowColumn {
			color: #006666;
		}
			
		.overRow .dojoxGrid-cell {
			text-decoration: underline;
		}
		
		.greenColumn {
			color: yellow;
			background-color: #006666;
			font-style: italic;
		}	
		.yellowColumnData {
			background-color: yellow;
			text-decoration: underline;
		}
	</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" src="support/test_data.js"></script>
	<script type="text/javascript">
		// grid structure
		// a grid view is a group of columns
		
		// a view without scrollbars
		var leftView = {
			noscroll: true,
			cells: [[
				{name: 'Column 0', width: 5, headerStyles: 'padding-bottom: 2px;', styles: 'border-bottom: 1px dashed #333; border-right: 1px dashed #333; padding: 6px;'},
				{name: 'Column 1', width: 5, headerStyles: 'padding-bottom: 2px;', styles: 'text-align: right; border-bottom: 1px dashed #333; border-right: 1px dashed #333; padding: 6px;'}
		]]};
		
		var middleView = {
			cells: [[
				{name: 'Column 2'},
				{name: 'Column 3', headerStyles: 'background-image: none; background-color: #003333;', classes: 'greenColumn'},
				{name: 'Column 4', cellClasses: 'yellowColumnData', classes: 'yellowColumn', styles: 'text-align: center;' },
				{name: 'Column 5', headerStyles: 'background-image: none; background-color: #003333;', classes: 'greenColumn'},
				{name: 'Column 6'},
				{name: 'Column 7'},
		]]};
		
		// a grid structure is an array of views.
		var structure = [ leftView, middleView ];
		
		function onStyleRow(inRow) {
			with (inRow) {
				var i = index % 10;
				var special = (i > 2 && i < 6);
				if (odd)
					customStyles += ' color: orange;';
				if (selected)	
					customClasses += ' selectedRow';
				if (special)	
					customClasses += ' specialRow';
				if (over)	
					customClasses += ' overRow';
				if (!over && !selected)
					dojox.Grid.prototype.onStyleRow.apply(this, arguments);
			}	
		}
		
		dojo.addOnLoad(function() {
			window["grid"] = dijit.byId('grid');
		});
</script>
</head>
<body>
<div class="heading">dojox.Grid Styling Example</div>
<div id="grid" dojoType="dojox.Grid" onStyleRow="onStyleRow" model="model" structure="structure"></div>
</body>
</html>