Debian Codegraph @

dojox/grid/tests/enhanced/test_enhanced_grid_dnd.html

raw symbols SCIP
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2 "http://www.w3.org/TR/html4/loose.dtd">
3 <html dir="ltr">
4 <head>
5 <title>Test Dnd plugin of dojox.grid.EnhancedGrid</title>
6 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
7 <link rel=stylesheet href="support/common.css"/>
8 <style type="text/css">
9 @import "/dojo/tests/dnd/dndDefault.css";
10 body {
11 font-size: 0.9em;
12 font-family: Geneva, Arial, Helvetica, sans-serif;
13 padding: 0.5em;
14 }
15 .title {
16 text-align:center;
17 margin:1em;
18 }
19 .container {
20 display: block;
21 border: 3px solid #ccc;
22 padding: 1em 3em;
23 cursor: default;
24 radius: 8pt;
25 background: #fff;
26 -moz-border-radius: 8pt 8pt;
27 }
28 .myblock{
29 float: left;
30 margin: 10px;
31 margin-top: 0;
32 }
33 .cfgtable th,
34 .cfgtable td{
35 font-weight: bolder;
36 padding: 5px;
37 }
38 h3{
39 margin: 0;
40 }
41 #grid1, #grid2{
42 margin-bottom: 0px;
43 width: 50em;
44 height: 30em;
45 }
46 /*Sample - overwrite default cell style
47 .claro .dojoxGridCell{
48 border-color: transparent #D5CDB5 #D5CDB5 transparent !important;
49 }
50 .dj_ie6 .claro .dojoxGridCell{
51 border: 1px solid #F1F1F1 !important;
52 }*/
53 </style>
54 <script type="text/javascript" src="../../../../dojo/dojo.js"
55 data-dojo-config="isDebug:true, parseOnLoad: true"></script>
56 <script type="text/javascript" src="../../../../dijit/tests/_testCommon.js"></script>
57 <script type="text/javascript">
58 dojo.require("dojo.parser");
59 dojo.require("dojo.data.ItemFileWriteStore");
60 dojo.require("dojox.data.AtomReadStore");
61 dojo.require("dojox.data.XmlStore");
62 dojo.require("dojox.grid.EnhancedGrid");
63 dojo.require("dojox.grid.enhanced.plugins.Selector");
64 dojo.require("dojox.grid.enhanced.plugins.NestedSorting");
65 dojo.require("dojox.grid.enhanced.plugins.DnD");
66 dojo.require("dojox.grid.enhanced.plugins.GridSource");
67 dojo.require("dojo.dnd.Source");
68 dojo.require("dijit.form.CheckBox");
69 </script>
70 <script type="text/javascript" src="support/test_write_store_dnd.js"></script>
71 <script type="text/javascript" src="support/test_write_store_music.js"></script>
72 <script type="text/javascript">
73 var layout1 = [{
74 defaultCell: {width: 5},
75 rows: [
76 {field: "A"},
77 {field: "B"},
78 {field: "C"},
79 {field: "D"},
80 {field: "E"},
81 {field: "F"},
82 {field: "G", hidden: true},
83 {field: "H", hidden: true},
84 {field: "I", hidden: true},
85 {field: "J"},
86 {field: "K"},
87 {field: "L"},
88 {field: "M"},
89 {field: "N"},
90 {field: "O"},
91 {field: "P"},
92 {field: "Q"},
93 {field: "R"},
94 {field: "S"},
95 {field: "T"},
96 {field: "U"},
97 {field: "V"},
98 {field: "W"},
99 {field: "X"},
100 {field: "Y"},
101 {field: "Z"}
102 ]
103 }];
104 var layout2 = [
105 {//first view
106 rows:
107 [
108 { field: "Genre", width: '6'},
109 { field: "Artist", width: '5'},
110 { field: "Year", width: '6'},
111 { field: "Album", width: '12'},
112 { field: "Name", width: '17', hidden: true},
113 { field: "Length", width: '6'},
114 { field: "Track", width: '6'},
115 { field: "Composer", width: '15'},
116 { field: "Download Date", width: '10'},
117 { field: "Last Played", width: '10'}
118 ]
119 }
120 ];
121 var store_copy = new dojo.data.ItemFileWriteStore({
122 data: test_store_data[0]
123 });
124 var setIdentifierForNewItem = function(item, store, index){
125 console.log("setIdentifierForNewItem", index);
126 var attrs = store.getIdentityAttributes(item);
127 for(var i = attrs.length - 1; i >= 0; --i){
128 item[attrs[i]] = index + (new Date()).getTime();
129 }
130 return item;
131 };
132 var setDnDConfig = function(gridId, type, mode, selected){
133 var config = {};
134 config[type] = {};
135 config[type][mode] = selected;
136 dijit.byId(gridId).setupDnDConfig(config);
137 };
138 var setCopyOnly = function(gridId, selected){
139 dijit.byId(gridId).dndCopyOnly(selected);
140 };
141 var getRowData = function(grid, rowIndexes){
142 var cells = grid.layout.cells;
143 var store = grid.store;
144 var cache = grid._by_idx;
145 var res = "Grid Rows from " + grid.id + ":<br/>";
146 for(var i = 0; i < rowIndexes.length; ++i){
147 var r = rowIndexes[i];
148 res += "Row " + r + ": ";
149 for(var j = 0; j < cells.length; ++j){
150 if(!cells[j].hidden){
151 res += store.getValue(cache[r].item, cells[j].field) + ", ";
152 }
153 }
154 res = res.substring(0, res.length - 2) + ";<br/>";
155 }
156 return res;
157 };
158 dojo.addOnLoad(function(){
159 dojo.query("input.cfgbox").forEach(function(cb){
160 cb.checked = true;
161 });
162 dojo.query("input.copyonlyCBox").forEach(function(cb){
163 cb.checked = false;
164 });
165 });
166 var newItem1 = {A: "new a1", B: "new b1", C: "new c1", D: "new d1",E: "new e1",F: "new f1",G: "new g1",H: "new h1",I: "new i1",J: "new j1",K: "new k1",L: "new l1",M: "new m1",N: "new n1",O: "new o1",P: "new c1",Q: "new q1",R: "new r1",S: "new s1",T: "new t1",U: "new u1",V: "new v1",W: "new w1",X: "new x1",Y: "new y1",Z: "new z1"};
167 var newItem2 = {A: "new a2", B: "new b2", C: "new c2", D: "new d2",E: "new e2",F: "new f2",G: "new g2",H: "new h2",I: "new i2",J: "new j2",K: "new k2",L: "new l2",M: "new m2",N: "new n2",O: "new o2",P: "new c2",Q: "new q2",R: "new r2",S: "new s2",T: "new t2",U: "new u2",V: "new v2",W: "new w2",X: "new x2",Y: "new y2",Z: "new z2"};
168 var newItem3 = {A: "new a3", B: "new b3", C: "new c3", D: "new d3",E: "new e3",F: "new f3",G: "new g3",H: "new h3",I: "new i3",J: "new j3",K: "new k3",L: "new l3",M: "new m3",N: "new n3",O: "new o3",P: "new c3",Q: "new q3",R: "new r3",S: "new s3",T: "new t3",U: "new u3",V: "new v3",W: "new w3",X: "new x3",Y: "new y3",Z: "new z3"};
169 </script>
170 </head>
171 <body class="claro">
172 <h1 class="title">dojox.grid.EnhancedGrid - DnD</h1>
173 <div class="myblock">
174 <h3>Grid 1</h3>
175 <div id="grid1" dojoType="dojox.grid.EnhancedGrid" rowsPerPage="16"
176 canSort="false",
177 plugins='{
178 dnd: {
179 "setIdentifierForNewItem": setIdentifierForNewItem, copyOnly: true,
180 "dndConfig": {
181 }
182 }
183 }' store="test_store[0]" structure="layout1" rowSelector="20px">
184 </div>
185 </div>
186 <div class="myblock">
187 <h3>Grid 2</h3>
188 <div id="grid2" dojoType="dojox.grid.EnhancedGrid" rowsPerPage="16"
189 canSort="false",
190 plugins='{
191 dnd: {
192 "setIdentifierForNewItem": setIdentifierForNewItem,
193 "dndConfig": {
194 }
195 }
196 }' store="store_copy" structure="layout1" rowSelector="20px">
197 </div>
198 </div>
199 <div class="myblock">
200 <h3>Grid 1 Configuration</h3>
201 <label style="font-weight: bolder;">Copy Only</label><input class="copyonlyCBox" type="checkbox" onchange="setCopyOnly('grid1', this.checked)" />
202 <table class="cfgtable" border="1">
203 <thead>
204 <tr>
205 <th>Drag</th>
206 <th>Within</th>
207 <th>In</th>
208 <th>Out</th>
209 </tr>
210 </thead>
211 <tbody>
212 <tr>
213 <td>Rows</td>
214 <td><input type="checkbox" class="cfgbox" onchange="setDnDConfig('grid1', 'row', 'within', this.checked)"/></td>
215 <td><input type="checkbox" class="cfgbox" onchange="setDnDConfig('grid1', 'row', 'in', this.checked)"/></td>
216 <td><input type="checkbox" class="cfgbox" onchange="setDnDConfig('grid1', 'row', 'out', this.checked)"/></td>
217 </tr>
218 <tr>
219 <td>Columns</td>
220 <td><input type="checkbox" class="cfgbox" onchange="setDnDConfig('grid1', 'col', 'within', this.checked)"/></td>
221 <td>Not implemented</td>
222 <td><input type="checkbox" class="cfgbox" onchange="setDnDConfig('grid1', 'col', 'out', this.checked)"/></td>
223 </tr>
224 <tr>
225 <td>Cells</td>
226 <td><input type="checkbox" class="cfgbox" onchange="setDnDConfig('grid1', 'cell', 'within', this.checked)"/></td>
227 <td><input type="checkbox" class="cfgbox" onchange="setDnDConfig('grid1', 'cell', 'in', this.checked)"/></td>
228 <td><input type="checkbox" class="cfgbox" onchange="setDnDConfig('grid1', 'cell', 'out', this.checked)"/></td>
229 </tr>
230 </tbody>
231 </table>
232 </div>
233 <div class="myblock">
234 <h3>Grid 2 Configuration</h3>
235 <label style="font-weight: bolder;">Copy Only</label><input class="copyonlyCBox" type="checkbox" onchange="setCopyOnly('grid2', this.checked)" />
236 <table class="cfgtable" border="1">
237 <thead>
238 <tr>
239 <th>Drag</th>
240 <th>Within</th>
241 <th>In</th>
242 <th>Out</th>
243 </tr>
244 </thead>
245 <tbody>
246 <tr>
247 <td>Rows</td>
248 <td><input type="checkbox" class="cfgbox" onchange="setDnDConfig('grid2', 'row', 'within', this.checked)"/></td>
249 <td><input type="checkbox" class="cfgbox" onchange="setDnDConfig('grid2', 'row', 'in', this.checked)"/></td>
250 <td><input type="checkbox" class="cfgbox" onchange="setDnDConfig('grid2', 'row', 'out', this.checked)"/></td>
251 </tr>
252 <tr>
253 <td>Columns</td>
254 <td><input type="checkbox" class="cfgbox" onchange="setDnDConfig('grid2', 'col', 'within', this.checked)"/></td>
255 <td>Not implemented</td>
256 <td><input type="checkbox" class="cfgbox" onchange="setDnDConfig('grid2', 'col', 'out', this.checked)"/></td>
257 </tr>
258 <tr>
259 <td>Cells</td>
260 <td><input type="checkbox" class="cfgbox" onchange="setDnDConfig('grid2', 'cell', 'within', this.checked)"/></td>
261 <td><input type="checkbox" class="cfgbox" onchange="setDnDConfig('grid2', 'cell', 'in', this.checked)"/></td>
262 <td><input type="checkbox" class="cfgbox" onchange="setDnDConfig('grid2', 'cell', 'out', this.checked)"/></td>
263 </tr>
264 </tbody>
265 </table>
266 </div>
267 <div class="myblock" style="clear: left;">
268 <h3>Ordinary Target (Can not accept grid contents)</h3>
269 <div dojoType="dojo.dnd.Source" class="container">
270 <div class="dojoDndItem">Item <strong>X</strong></div>
271 <div class="dojoDndItem">Item <strong>Y</strong></div>
272 <div class="dojoDndItem">Item <strong>Z</strong></div>
273 </div>
274 </div>
275 <div class="myblock">
276 <h3>Target that can accept Grid</h3>
277 <div dojoType="dojox.grid.enhanced.plugins.GridSource" class="container"
278 insertNodesForGrid="true" getRowContent="getRowData">
279 <div class="dojoDndItem">Item 1</div>
280 <div class="dojoDndItem">Item 2</div>
281 <div class="dojoDndItem">Item 3</div>
282 </div>
283 </div>
284 <div class="myblock">
285 <h3>Grid Acceptable Source (Drag item to grid)</h3>
286 <div dojoType="dojo.dnd.Source" class="container">
287 <div class="dojoDndItem" dndType="grid/rows" dndData="newItem1">Item 1</div>
288 <div class="dojoDndItem" dndType="grid/rows" dndData="newItem2">Item 2</div>
289 <div class="dojoDndItem" dndType="grid/rows" dndData="newItem3">Item 3</div>
290 </div>
291 </div>
292 <p style="clear: left;"><strong>Note:</strong> To see the tundra theme, just append <b style="color:blue;">?theme=tundra</b> to the URL.</p>
293 </body>
294 </html>