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 XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
<html xmlns="http://www.w3.org/1999/xhtml">
3
<head>
4
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
5
<title>Test dojox.Grid Editing</title>
6
<style>
7
	@import "../_grid/Grid.css";
8
	body {
9
		font-family: Tahoma, Arial, Helvetica, sans-serif;
10
		font-size: 11px;
11
	}
12
	.dojoxGrid-row-editing td {
13
		background-color: #F4FFF4;
14
	}
15
	.dojoxGrid input, .dojoxGrid select, .dojoxGrid textarea {
16
		margin: 0;
17
		padding: 0;
18
		border-style: none;
19
		width: 100%;
20
		font-size: 100%;
21
		font-family: inherit;
22
	}
23
	.dojoxGrid input {
24
	}
25
	.dojoxGrid select {
26
	}
27
	.dojoxGrid textarea {
28
	}
29
	#controls {
30
		padding: 6px 0;
31
	}
32
	#grid {
33
		width: 850px;
34
		height: 350px;
35
		border: 1px solid silver;
36
	}
37
</style>
38
	<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug:false, parseOnLoad: true"></script>
39
	<!--<script type="text/javascript">
40
		dojo.require("dojox.grid.Grid");
41
		dojo.require("dojox.grid._data.model");
42
		dojo.require("dojo.parser");
43
	</script>-->
44
	<!-- Debugging -->
45
	<script type="text/javascript" src="../_grid/lib.js"></script>
46
	<script type="text/javascript" src="../_grid/drag.js"></script>
47
	<script type="text/javascript" src="../_grid/scroller.js"></script>
48
	<script type="text/javascript" src="../_grid/builder.js"></script>
49
	<script type="text/javascript" src="../_grid/cell.js"></script>
50
	<script type="text/javascript" src="../_grid/layout.js"></script>
51
	<script type="text/javascript" src="../_grid/rows.js"></script>
52
	<script type="text/javascript" src="../_grid/focus.js"></script>
53
	<script type="text/javascript" src="../_grid/selection.js"></script>
54
	<script type="text/javascript" src="../_grid/edit.js"></script>
55
	<script type="text/javascript" src="../_grid/view.js"></script>
56
	<script type="text/javascript" src="../_grid/views.js"></script>
57
	<script type="text/javascript" src="../_grid/rowbar.js"></script>
58
	<script type="text/javascript" src="../_grid/publicEvents.js"></script>
59
	<script type="text/javascript" src="../VirtualGrid.js"></script>
60
	<script type="text/javascript" src="../_data/fields.js"></script>
61
	<script type="text/javascript" src="../_data/model.js"></script>
62
	<script type="text/javascript" src="../_data/editors.js"></script>
63
	<script type="text/javascript" src="../Grid.js"></script>
64
	<script type="text/javascript">
65
	// ==========================================================================
66
	// Create a data model
67
	// ==========================================================================
68
	data = [
69
		[ "normal", false, "new", 'But are not followed by two hexadecimal', 29.91, 10, false ],
70
		[ "important", false, "new", 'Because a % sign always indicates', 9.33, -5, false ],
71
		[ "important", false, "read", 'Signs can be selectively', 19.34, 0, true ],
72
		[ "note", false, "read", 'However the reserved characters', 15.63, 0, true ],
73
		[ "normal", false, "replied", 'It is therefore necessary', 24.22, 5.50, true ],
74
		[ "important", false, "replied", 'To problems of corruption by', 9.12, -3, true ],
75
		[ "note", false, "replied", 'Which would simply be awkward in', 12.15, -4, false ]
76
	];
77
	var rows = 10000;
78
	for(var i=0, l=data.length; i<rows-l; i++){
79
		data.push(data[i%l].slice(0));
80
	}
81
	model = new dojox.grid.data.Table(null, data);
82
	// ==========================================================================
83
	// Tie some UI to the data model
84
	// ==========================================================================
85
	model.observer(this);
86
	modelChange = function() {
87
		dojo.byId("rowCount").innerHTML = 'Row count: ' + model.count;
88
	}
89
	// ==========================================================================
90
	// Custom formatter
91
	// ==========================================================================
92
	formatMoney = function(inDatum) {
93
		return isNaN(inDatum) ? '...' : '$' + parseFloat(inDatum).toFixed(2);
94
	}
95
	// ==========================================================================
96
	// Grid structure
97
	// ==========================================================================
98
	statusCell = { field: 2, name: 'Status', styles: 'text-align: center;', editor: dojox.grid.editors.Select, options: [ "new", "read", "replied" ] };
99
	gridLayout = [{
100
		type: 'dojox.GridRowView', width: '20px'
101
	},{
102
		defaultCell: { width: 8, editor: dojox.grid.editors.Input, styles: 'text-align: right;'  },
103
		rows: [[
104
			{ name: 'Id', width: 3, get: function(inRowIndex) { return inRowIndex+1;} },
105
			{ name: 'Priority', styles: 'text-align: center;', editor: dojox.grid.editors.Select, options: ["normal", "note", "important"]},
106
			{ name: 'Mark', width: 3, styles: 'text-align: center;', editor: dojox.grid.editors.Bool },
107
			statusCell,
108
			{ name: 'Message', styles: '', width: '100%' },
109
			{ name: 'Amount', formatter: formatMoney },
110
			{ name: 'Amount', field: 4, formatter: formatMoney }
111
		]]
112
	},{
113
		defaultCell: { width: 4, editor: dojox.grid.editors.Input, styles: 'text-align: right;' },
114
		rows: [[
115
			{ name: 'Mark', width: 3, field: 1, styles: 'text-align: center;', editor: dojox.grid.editors.Bool},
116
			statusCell,
117
			{ name: 'Amount', field: 4, formatter: formatMoney},
118
			{ name: 'Detail', value: 'Detail'}
119
		]]
120
	}];
121
	// ==========================================================================
122
	// UI Action
123
	// ==========================================================================
124
	addRow = function(){
125
		grid.addRow([ "normal", false, "new", 'Now is the time for all good men to come to the aid of their party.', 99.99, 9.99, false ]);
126
	}
127
</script>
128
</head>
129
<body>
130
<h2>
131
	dojox.Grid Basic Editing test
132
</h2>
133
<div id="controls">
134
	<button onclick="grid.refresh()">Refresh</button>&nbsp;&nbsp;&nbsp;
135
	<button onclick="grid.edit.focusEditor()">Focus Editor</button>
136
	<button onclick="grid.focus.next()">Next Focus</button>&nbsp;&nbsp;&nbsp;
137
	<button onclick="addRow()">Add Row</button>
138
	<button onclick="grid.removeSelectedRows()">Remove</button>&nbsp;&nbsp;&nbsp;
139
	<button onclick="grid.edit.apply()">Apply</button>
140
	<button onclick="grid.edit.cancel()">Cancel</button>&nbsp;&nbsp;&nbsp;
141
	<button onclick="grid.singleClickEdit = !grid.singleClickEdit">Toggle singleClickEdit</button>&nbsp;
142
</div>
143
<br />
144
<div id="grid" dojoType="dojox.Grid"
145
	jsId="grid"
146
	model="model" structure="gridLayout"></div>
147
<br />
148
<div id="rowCount"></div>
149
</body>
150
</html>