2150 |
mathias |
1 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
|
2 |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
|
3 |
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
|
4 |
<head>
|
|
|
5 |
<title>Test dojox.Grid Editing</title>
|
|
|
6 |
<style>
|
|
|
7 |
@import "../_grid/tundraGrid.css";
|
|
|
8 |
@import "../../../dojo/resources/dojo.css";
|
|
|
9 |
@import "../../../dijit/themes/tundra/tundra.css";
|
|
|
10 |
@import "../../../dijit/tests/css/dijitTests.css";
|
|
|
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 |
|
|
|
30 |
#controls {
|
|
|
31 |
padding: 6px 0;
|
|
|
32 |
}
|
|
|
33 |
#controls button {
|
|
|
34 |
margin-left: 10px;
|
|
|
35 |
}
|
|
|
36 |
.myGrid {
|
|
|
37 |
width: 850px;
|
|
|
38 |
height: 350px;
|
|
|
39 |
border: 1px solid silver;
|
|
|
40 |
}
|
|
|
41 |
</style>
|
|
|
42 |
<script type="text/javascript" src="../../../dojo/dojo.js"
|
|
|
43 |
djConfig="isDebug:false, parseOnLoad: true"></script>
|
|
|
44 |
<script type="text/javascript">
|
|
|
45 |
dojo.require("dojox.grid.Grid");
|
|
|
46 |
dojo.require("dojox.grid._data.model");
|
|
|
47 |
dojo.require("dojo.parser");
|
|
|
48 |
</script>
|
|
|
49 |
<script type="text/javascript">
|
|
|
50 |
// ==========================================================================
|
|
|
51 |
// Create a data model
|
|
|
52 |
// ==========================================================================
|
|
|
53 |
data = [
|
|
|
54 |
[ "normal", false, "new", 'But are not followed by two hexadecimal', 29.91, 10, false ],
|
|
|
55 |
[ "important", false, "new", 'Because a % sign always indicates', 9.33, -5, false ],
|
|
|
56 |
[ "important", false, "read", 'Signs can be selectively', 19.34, 0, true ],
|
|
|
57 |
[ "note", false, "read", 'However the reserved characters', 15.63, 0, true ],
|
|
|
58 |
[ "normal", false, "replied", 'It is therefore necessary', 24.22, 5.50, true ],
|
|
|
59 |
[ "important", false, "replied", 'To problems of corruption by', 9.12, -3, true ],
|
|
|
60 |
[ "note", false, "replied", 'Which would simply be awkward in', 12.15, -4, false ]
|
|
|
61 |
];
|
|
|
62 |
var rows = 10000;
|
|
|
63 |
for(var i=0, l=data.length; i<rows-l; i++){
|
|
|
64 |
data.push(data[i%l].slice(0));
|
|
|
65 |
}
|
|
|
66 |
model = new dojox.grid.data.Table(null, data);
|
|
|
67 |
|
|
|
68 |
// ==========================================================================
|
|
|
69 |
// Tie some UI to the data model
|
|
|
70 |
// ==========================================================================
|
|
|
71 |
model.observer(this);
|
|
|
72 |
modelChange = function(){
|
|
|
73 |
dojo.byId("rowCount").innerHTML = 'Row count: ' + model.count;
|
|
|
74 |
}
|
|
|
75 |
|
|
|
76 |
// ==========================================================================
|
|
|
77 |
// Custom formatter
|
|
|
78 |
// ==========================================================================
|
|
|
79 |
formatMoney = function(inDatum){
|
|
|
80 |
return isNaN(inDatum) ? '...' : '$' + parseFloat(inDatum).toFixed(2);
|
|
|
81 |
}
|
|
|
82 |
|
|
|
83 |
// ==========================================================================
|
|
|
84 |
// Grid structure
|
|
|
85 |
// ==========================================================================
|
|
|
86 |
statusCell = {
|
|
|
87 |
field: 2,
|
|
|
88 |
name: 'Status',
|
|
|
89 |
styles: 'text-align: center;',
|
|
|
90 |
editor: dojox.grid.editors.Select,
|
|
|
91 |
options: [ "new", "read", "replied" ]
|
|
|
92 |
};
|
|
|
93 |
|
|
|
94 |
gridLayout = [
|
|
|
95 |
{
|
|
|
96 |
type: 'dojox.GridRowView', width: '20px'
|
|
|
97 |
},
|
|
|
98 |
{
|
|
|
99 |
defaultCell: { width: 8, editor: dojox.grid.editors.Input, styles: 'text-align: right;' },
|
|
|
100 |
rows: [
|
|
|
101 |
[
|
|
|
102 |
{ name: 'Id', width: 3, get: function(inRowIndex){ return inRowIndex+1;} },
|
|
|
103 |
{ name: 'Priority', styles: 'text-align: center;', editor: dojox.grid.editors.Select, options: ["normal", "note", "important"]},
|
|
|
104 |
{ name: 'Mark', width: 3, styles: 'text-align: center;', editor: dojox.grid.editors.Bool },
|
|
|
105 |
statusCell,
|
|
|
106 |
{ name: 'Message', styles: '', width: '100%' },
|
|
|
107 |
{ name: 'Amount', formatter: formatMoney }
|
|
|
108 |
]
|
|
|
109 |
]
|
|
|
110 |
}
|
|
|
111 |
];
|
|
|
112 |
// ==========================================================================
|
|
|
113 |
// UI Action
|
|
|
114 |
// ==========================================================================
|
|
|
115 |
addRow = function() {
|
|
|
116 |
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 ]);
|
|
|
117 |
}
|
|
|
118 |
</script>
|
|
|
119 |
</head>
|
|
|
120 |
<body class="tundra">
|
|
|
121 |
<h1>dojox.Grid Basic Editing test</h1>
|
|
|
122 |
<br />
|
|
|
123 |
<div id="controls">
|
|
|
124 |
<button onclick="grid.refresh()">Refresh</button>
|
|
|
125 |
<button onclick="grid.edit.focusEditor()">Focus Editor</button>
|
|
|
126 |
<button onclick="grid.focus.next()">Next Focus</button>
|
|
|
127 |
<button onclick="addRow()">Add Row</button>
|
|
|
128 |
<button onclick="grid.removeSelectedRows()">Remove</button>
|
|
|
129 |
<button onclick="grid.edit.apply()">Apply</button>
|
|
|
130 |
<button onclick="grid.edit.cancel()">Cancel</button>
|
|
|
131 |
<button onclick="grid.singleClickEdit = !grid.singleClickEdit">Toggle singleClickEdit</button>
|
|
|
132 |
</div>
|
|
|
133 |
<br />
|
|
|
134 |
<div jsId="grid" class="myGrid"
|
|
|
135 |
dojoType="dojox.Grid" model="model"
|
|
|
136 |
structure="gridLayout"></div>
|
|
|
137 |
<br />
|
|
|
138 |
<div id="rowCount"></div>
|
|
|
139 |
</body>
|
|
|
140 |
</html>
|