| 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 all plugins 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 | body { |
| 10 | font-size: 0.9em; |
| 11 | font-family: Geneva, Arial, Helvetica, sans-serif; |
| 12 | padding-right: 5em; |
| 13 | } |
| 14 | .title { |
| 15 | text-align:center; |
| 16 | margin:1em; |
| 17 | } |
| 18 | .supporter { |
| 19 | display: block; |
| 20 | border: 3px solid #ccc; |
| 21 | width: 100em; |
| 22 | padding: 1em 3em; |
| 23 | cursor: default; |
| 24 | radius: 8pt; |
| 25 | background: #fff; |
| 26 | -moz-border-radius: 8pt 8pt; |
| 27 | } |
| 28 | .selectReport { |
| 29 | display: inline-block; |
| 30 | } |
| 31 | .tutor h2{ |
| 32 | font-weight: bolder; |
| 33 | } |
| 34 | .tutor td:first-child{ |
| 35 | font-weight: bolder; |
| 36 | } |
| 37 | #gridContainer{ |
| 38 | width: 100em; |
| 39 | height: 35em; |
| 40 | border: 1px solid #D5CDB5; |
| 41 | } |
| 42 | /*Sample - overwrite default cell style |
| 43 | .claro .dojoxGridCell{ |
| 44 | border-color: transparent #D5CDB5 #D5CDB5 transparent !important; |
| 45 | } |
| 46 | .dj_ie6 .claro .dojoxGridCell{ |
| 47 | border: 1px solid #F1F1F1 !important; |
| 48 | }*/ |
| 49 | </style> |
| 50 | <script type="text/javascript" src="../../../../dojo/dojo.js" |
| 51 | data-dojo-config="isDebug:false, parseOnLoad: true"></script> |
| 52 | <script type="text/javascript" src="../../../../dijit/tests/_testCommon.js"></script> |
| 53 | <script type="text/javascript"> |
| 54 | dojo.require("dijit._WidgetsInTemplateMixin"); |
| 55 | dojo.require("dijit.form.CheckBox"); |
| 56 | dojo.require("dijit.form.DateTextBox"); |
| 57 | dojo.require("dojo.data.ItemFileWriteStore"); |
| 58 | dojo.require("dojox.grid.enhanced.plugins.Filter"); |
| 59 | dojo.require("dojox.grid.enhanced.plugins.exporter.CSVWriter"); |
| 60 | dojo.require("dojox.grid.enhanced.plugins.Printer"); |
| 61 | dojo.require("dojox.grid.enhanced.plugins.Cookie"); |
| 62 | dojo.require("dojox.grid.enhanced.plugins.IndirectSelection"); |
| 63 | dojo.require("dojox.grid.enhanced.plugins.NestedSorting"); |
| 64 | dojo.require("dojox.grid.enhanced.plugins.Selector"); |
| 65 | dojo.require("dojox.grid.enhanced.plugins.Menu"); |
| 66 | dojo.require("dojox.grid.enhanced.plugins.DnD"); |
| 67 | dojo.require("dojox.grid.enhanced.plugins.Search"); |
| 68 | dojo.require("dojox.grid.enhanced.plugins.CellMerge"); |
| 69 | dojo.require("dojox.grid.enhanced.plugins.Pagination"); |
| 70 | dojo.require("dojox.grid.enhanced.plugins.GridSource"); |
| 71 | dojo.require("dojox.grid.EnhancedGrid"); |
| 72 | dojo.require("dojo.parser"); |
| 73 | var startGridIndex = 0, |
| 74 | initialShowGrid = false, |
| 75 | hideCtrlPanel = false, |
| 76 | repeatCount = 100000, |
| 77 | repeatInterval = 500; |
| 78 | gridAttrs = { |
| 79 | rowsPerPage: 5, |
| 80 | keepSelection: true, |
| 81 | //sortFields: [{attribute: "Genre"}], |
| 82 | plugins: { |
| 83 | } |
| 84 | }; |
| 85 | </script> |
| 86 | <script type="text/javascript" src="support/test_write_store_music.js"></script> |
| 87 | <script type="text/javascript" src="support/test_layout_music.js"></script> |
| 88 | <script type="text/javascript" src="support/test_repeat.js"></script> |
| 89 | <script type="text/javascript"> |
| 90 | var plugins = { |
| 91 | "nestedSorting": {}, |
| 92 | "indirectSelection": { |
| 93 | headerSelector: true |
| 94 | }, |
| 95 | "menus": { |
| 96 | headerMenu: "headerMenu", |
| 97 | rowMenu: "rowMenu", |
| 98 | cellMenu: "cellMenu", |
| 99 | selectedRegionMenu: "selectedRegionMenu" |
| 100 | }, |
| 101 | "exporter": {}, |
| 102 | "printer": {}, |
| 103 | "filter": { |
| 104 | closeFilterbarButton: true, |
| 105 | ruleCount: 0 |
| 106 | }, |
| 107 | "cookie": {}, |
| 108 | "selector": {}, |
| 109 | "dnd": { |
| 110 | copyOnly: true |
| 111 | }, |
| 112 | "cellMerge": { |
| 113 | "mergedCells": [ |
| 114 | {row: "3", start: 1, end: 10, major: 3} |
| 115 | ] |
| 116 | }, |
| 117 | "search": {}, |
| 118 | "pagination": |
| 119 | { |
| 120 | pageSizes: ["5", "10", "20", "50", "All"], // Array, custom the items per page button |
| 121 | // itemTitle: "entrys", // String, custom the item' title of description |
| 122 | description: true, // boolean, custom weather or not the discription will be displayed |
| 123 | sizeSwitch: true, // boolean, custom weather or not the page size switch will be displayed |
| 124 | pageStepper: true, // boolean, custom weather or not the page step will be displayed |
| 125 | gotoButton: true, |
| 126 | maxPageStep: 10, // Integer, custom how many page step will be displayed |
| 127 | position: "bottom" // String, custom the position of the paginator bar |
| 128 | // there're three options: top, bottom, both |
| 129 | // ,descTemplate: "${1} ${0}" // A template of the current position description. |
| 130 | } |
| 131 | }; |
| 132 | var gridFeatures = { |
| 133 | "canSort": { |
| 134 | label: "disable canSort", |
| 135 | value: function(colIndex){ |
| 136 | return false; |
| 137 | } |
| 138 | }, |
| 139 | "rowSelector": { |
| 140 | value: "20px" |
| 141 | }, |
| 142 | "autoHeight": { |
| 143 | value: true |
| 144 | }, |
| 145 | "autoWidth": { |
| 146 | value: true |
| 147 | }, |
| 148 | "singleClickEdit": { |
| 149 | value: true |
| 150 | }, |
| 151 | "selectionMode": { |
| 152 | label: "single selectionMode", |
| 153 | value: "single" |
| 154 | }, |
| 155 | "columnReordering": { |
| 156 | value: true |
| 157 | } |
| 158 | }; |
| 159 | function getTableString(){ |
| 160 | var sb = ["<table><tbody>"]; |
| 161 | for(var featureName in gridFeatures){ |
| 162 | sb.push("<tr>"); |
| 163 | sb.push("<td><input id='cbid", featureName, |
| 164 | "' dojoType='dijit.form.CheckBox' dojoAttachPoint='cb", featureName, |
| 165 | "'><label id='lbl", featureName, "' for='cbid", featureName, "'>", |
| 166 | gridFeatures[featureName].label || featureName, "</label></input></td>" |
| 167 | ); |
| 168 | sb.push("</tr>"); |
| 169 | } |
| 170 | sb.push("<tr><td><hr/></td></tr>", |
| 171 | "<tr><td><button onclick='selectAll()'>Select All</button>", |
| 172 | "<button onclick='deselectAll()'>Deselect All</button></td></tr>" |
| 173 | ); |
| 174 | for(var pluginName in plugins){ |
| 175 | sb.push("<tr>"); |
| 176 | sb.push("<td><input id='cbid", pluginName, |
| 177 | "' dojoType='dijit.form.CheckBox' dojoAttachPoint='cb", pluginName, |
| 178 | "'><label id='lbl", pluginName, "' for='cbid", pluginName, "'>", |
| 179 | pluginName, "</label></input></td>" |
| 180 | ); |
| 181 | sb.push("</tr>"); |
| 182 | } |
| 183 | sb.push("</tbody></table>"); |
| 184 | return sb.join(''); |
| 185 | } |
| 186 | dojo.declare("PluginTable", [dijit._Widget, dijit._TemplatedMixin, dijit._WidgetsInTemplateMixin], { |
| 187 | templateString: getTableString(), |
| 188 | widgetsInTemplate: true, |
| 189 | _onChangePlugin: function(pluginName, cb, e){ |
| 190 | var checked = cb.get("checked"); |
| 191 | gridAttrs.plugins[pluginName] = checked ? plugins[pluginName] : false; |
| 192 | var nd = dojo.byId(pluginName + "Support"); |
| 193 | if(nd){ |
| 194 | dojo.style(nd, "display", checked ? "" : "none"); |
| 195 | } |
| 196 | }, |
| 197 | _onChangeFeature: function(featureName, cb, e){ |
| 198 | var checked = cb.get("checked"); |
| 199 | if(checked){ |
| 200 | gridAttrs[featureName] = gridFeatures[featureName].value; |
| 201 | }else{ |
| 202 | delete gridAttrs[featureName]; |
| 203 | } |
| 204 | }, |
| 205 | postCreate: function(){ |
| 206 | var cb; |
| 207 | for(var featureName in gridFeatures){ |
| 208 | cb = this["cb" + featureName]; |
| 209 | this.connect(cb, "onChange", dojo.hitch(this, "_onChangeFeature", featureName, cb)); |
| 210 | } |
| 211 | for(var pluginName in plugins){ |
| 212 | cb = this["cb" + pluginName]; |
| 213 | this.connect(cb, "onChange", dojo.hitch(this, "_onChangePlugin", pluginName, cb)); |
| 214 | } |
| 215 | } |
| 216 | }); |
| 217 | function selectAll(){ |
| 218 | for(var pluginName in plugins){ |
| 219 | dijit.byId("cbid" + pluginName).set("checked", true); |
| 220 | } |
| 221 | } |
| 222 | function deselectAll(){ |
| 223 | for(var pluginName in plugins){ |
| 224 | dijit.byId("cbid" + pluginName).set("checked", false); |
| 225 | } |
| 226 | } |
| 227 | function exportCSV(){ |
| 228 | var g = dijit.byId("grid"); |
| 229 | g && g.exportGrid("csv", { |
| 230 | writerArgs: { |
| 231 | separator: dojo.byId('sep').value |
| 232 | } |
| 233 | }, function(str){ |
| 234 | dojo.byId("csvResults").value = str; |
| 235 | }); |
| 236 | } |
| 237 | function exportSelected(){ |
| 238 | var g = dijit.byId("grid"); |
| 239 | if(g){ |
| 240 | dojo.byId("csvResults").value = g.exportSelected("csv", { |
| 241 | separator: dojo.byId('sep').value |
| 242 | }); |
| 243 | } |
| 244 | } |
| 245 | function printGrid(){ |
| 246 | var g = dijit.byId("grid"); |
| 247 | if(g){ |
| 248 | // g.setExportFormatter(function(data, cell, rowIndex, rowItem){ |
| 249 | // if(cell.field === "Year"){ |
| 250 | // return parseInt(data, 10) * 2; |
| 251 | // }else{ |
| 252 | // return data; |
| 253 | // } |
| 254 | // }); |
| 255 | g.printGrid({ |
| 256 | title: dojo.byId('print_title').value, |
| 257 | cssFiles: ["support/print_style1.css","support/print_style2.css"] |
| 258 | }); |
| 259 | } |
| 260 | } |
| 261 | function printSelected(){ |
| 262 | var g = dijit.byId("grid"); |
| 263 | g && g.printSelected({ |
| 264 | title: dojo.byId('print_title').value, |
| 265 | cssFiles: ["support/print_style1.css", "support/print_style2.css"] |
| 266 | }); |
| 267 | } |
| 268 | function printPreview(){ |
| 269 | var g = dijit.byId("grid"); |
| 270 | g && g.exportToHTML({ |
| 271 | title: dojo.byId('print_title').value, |
| 272 | cssFiles: ["support/print_style1.css", "support/print_style2.css"] |
| 273 | }, function(str){ |
| 274 | var win = window.open(); |
| 275 | win.document.open(); |
| 276 | win.document.write(str); |
| 277 | g.normalizePrintedGrid(win.document); |
| 278 | win.document.close(); |
| 279 | }); |
| 280 | } |
| 281 | function mergeCells(){ |
| 282 | var rowIndex = parseInt(dojo.byId("inputRow").value, 10) - 1; |
| 283 | var start = parseInt(dojo.byId("inputStart").value, 10); |
| 284 | var end = parseInt(dojo.byId("inputEnd").value, 10); |
| 285 | var major = parseInt(dojo.byId("inputMajor").value, 10); |
| 286 | var grid = dijit.byId("grid"); |
| 287 | grid.mergeCells(rowIndex, start, end, major); |
| 288 | } |
| 289 | function getInput(str){ |
| 290 | var start = str.indexOf('/'); |
| 291 | var end = str.lastIndexOf('/'); |
| 292 | if(start == 0 || end > 1){ |
| 293 | var regstr = str.substring(start + 1, end); |
| 294 | var modifiers = str.substring(end + 1, str.length); |
| 295 | str = new RegExp(regstr,modifiers); |
| 296 | } |
| 297 | console.log("input:", str); |
| 298 | return str; |
| 299 | } |
| 300 | function onSearched(resultId, rowIdx){ |
| 301 | console.log("search result:", rowIdx); |
| 302 | if(rowIdx < 0){ |
| 303 | dojo.byId(resultId).innerHTML = "Not Found!"; |
| 304 | }else{ |
| 305 | dojo.byId(resultId).innerHTML = "Search result is Row " + (rowIdx + 1); |
| 306 | dijit.byId("grid").scrollToRow(rowIdx, true); |
| 307 | } |
| 308 | } |
| 309 | function onSearch(){ |
| 310 | var g = dijit.byId("grid"); |
| 311 | if(g){ |
| 312 | var args = {}; |
| 313 | dojo.query(".searchInput").forEach(function(input){ |
| 314 | var v = dojo.trim(input.value); |
| 315 | if(v){ |
| 316 | args[input.name] = getInput(v); |
| 317 | } |
| 318 | }); |
| 319 | console.log("search arguments:", args); |
| 320 | g.searchRow(args, dojo.partial(onSearched, "result2")); |
| 321 | } |
| 322 | } |
| 323 | function onSearchAll(input){ |
| 324 | var g = dijit.byId("grid"); |
| 325 | g && g.searchRow(getInput(input), dojo.partial(onSearched, "result1")); |
| 326 | } |
| 327 | function enableCookie(key, toEnable){ |
| 328 | console.log(key,toEnable); |
| 329 | try{ |
| 330 | var g = dijit.byId("grid"); |
| 331 | if(g){ |
| 332 | if(key){ |
| 333 | g.setCookieEnabled(key, toEnable); |
| 334 | }else{ |
| 335 | g.setCookieEnabled(toEnable); |
| 336 | } |
| 337 | } |
| 338 | }catch(e){ |
| 339 | console.log(e); |
| 340 | } |
| 341 | } |
| 342 | function setupSelectorTest(){ |
| 343 | var grid = dijit.byId("grid"), |
| 344 | func = function(type, start, end, selected){ |
| 345 | fill("col", selected["col"]); |
| 346 | fill("row", selected["row"]); |
| 347 | fill("cell", selected["cell"]); |
| 348 | }, |
| 349 | fill = function(type, selected){ |
| 350 | var getString; |
| 351 | var cells = grid.layout.cells; |
| 352 | switch(type){ |
| 353 | case "col": |
| 354 | getString = function(item){ |
| 355 | return "Column " + item.col + ": " + dojo.toJson(item.except); |
| 356 | } |
| 357 | break; |
| 358 | case "row": |
| 359 | getString = function(item){ |
| 360 | return "Row " + item.row + ": " + dojo.toJson(item.except); |
| 361 | } |
| 362 | break; |
| 363 | case "cell": |
| 364 | getString = function(item){ |
| 365 | return "Cell " + item.row + " , " + item.col; |
| 366 | } |
| 367 | } |
| 368 | dojo.attr(dojo.byId(type + "s"), "value", dojo.map(selected, function(item){ |
| 369 | return getString(item); |
| 370 | }).join('\n')); |
| 371 | dojo.attr(dojo.byId(type + "Cnt"), "value", selected.length); |
| 372 | }; |
| 373 | grid.connect(grid, "onEndSelect", func); |
| 374 | grid.connect(grid, "onEndDeselect", func); |
| 375 | } |
| 376 | dojo.declare("TestWidget", [dijit._Widget,dijit._TemplatedMixin], { |
| 377 | templateString: dojo.cache("dojox.grid", "enhanced/templates/ClearFilterConfirmPane.html"), |
| 378 | widgetsInTemplate: true, |
| 379 | _clearBtnLabel: "clearButton", |
| 380 | _cancelBtnLabel: "cancelButton", |
| 381 | _clearFilterMsg: "clearFilterMsg", |
| 382 | _onCancel: function(){}, |
| 383 | _onClear: function(){} |
| 384 | }); |
| 385 | var rpCnt = 0; |
| 386 | var dlg; |
| 387 | function testDialog(){ |
| 388 | if(dlg){ |
| 389 | dlg.destroyRecursive(); |
| 390 | dlg = null; |
| 391 | } |
| 392 | dlg = new dijit.Dialog({ |
| 393 | title: "title", |
| 394 | content: new TestWidget({}) |
| 395 | }); |
| 396 | dojo.byId("repeatcounter").innerHTML = ++rpCnt; |
| 397 | setTimeout(testDialog, 100); |
| 398 | } |
| 399 | function testStore(){ |
| 400 | var store = test_store[0]; |
| 401 | if(store.unwrap){ |
| 402 | store.unwrap("sort").unwrap("unique").unwrap("filter"); |
| 403 | } |
| 404 | var ns = dojox.grid.enhanced.plugins; |
| 405 | ns.wrap(ns.wrap(ns.wrap(store, |
| 406 | new ns.filter.ClientSideFilterLayer()), |
| 407 | new ns.filter.UniqueLayer()), |
| 408 | new ns.filter.SortLayer()); |
| 409 | dojo.byId("repeatcounter").innerHTML = ++rpCnt; |
| 410 | setTimeout(testStore, 100); |
| 411 | } |
| 412 | var hdl; |
| 413 | function testConnect(){ |
| 414 | if(hdl){ |
| 415 | dojo.disconnect(hdl); |
| 416 | } |
| 417 | hdl = dojo.connect(undefined, "aaaaaa", window, function(){}); |
| 418 | dojo.byId("repeatcounter").innerHTML = ++rpCnt; |
| 419 | setTimeout(testConnect, 100); |
| 420 | } |
| 421 | function scrollToRow(){ |
| 422 | var g = dijit.byId("grid"); |
| 423 | if(g){ |
| 424 | var idx = parseInt(dojo.byId("inputScrollToRowIdx").value, 10); |
| 425 | console.log("scroll to ", idx); |
| 426 | g.scrollToRow(idx); |
| 427 | } |
| 428 | } |
| 429 | dojo.addOnLoad(function(){ |
| 430 | var btns = dojo.byId("ctrlBtns2"); |
| 431 | btns.appendChild(dojo.create("button",{ |
| 432 | "innerHTML": "Refresh", |
| 433 | "onclick": function(){ |
| 434 | var g = dijit.byId("grid"); |
| 435 | g && g._refresh(); |
| 436 | } |
| 437 | })); |
| 438 | btns.appendChild(dojo.create("button",{ |
| 439 | "innerHTML": "Delete Selected", |
| 440 | "onclick": function(){ |
| 441 | var g = dijit.byId("grid"); |
| 442 | g && g.removeSelectedRows(); |
| 443 | } |
| 444 | })); |
| 445 | btns.appendChild(dojo.create("button",{ |
| 446 | "innerHTML": "Set Store", |
| 447 | "onclick": function(){ |
| 448 | var g = dijit.byId("grid"); |
| 449 | var data = dojo.clone(test_store_data[0]); |
| 450 | data.items = data.items.slice(0, 50); |
| 451 | console.log(data); |
| 452 | g && g.setStore(new dojo.data.ItemFileWriteStore({ |
| 453 | data: data |
| 454 | })); |
| 455 | } |
| 456 | })); |
| 457 | btns.appendChild(dojo.create("button",{ |
| 458 | "innerHTML": "Set Structure", |
| 459 | "onclick": function(){ |
| 460 | var g = dijit.byId("grid"); |
| 461 | g && g.set("structure", layout[5]); |
| 462 | } |
| 463 | })); |
| 464 | btns.appendChild(dojo.create("button",{ |
| 465 | "innerHTML": "Add Row", |
| 466 | "onclick": function(){ |
| 467 | var g = dijit.byId("grid"); |
| 468 | g && g.addRow(); |
| 469 | } |
| 470 | })); |
| 471 | btns.appendChild(dojo.create("button",{ |
| 472 | "innerHTML": "Get Selected", |
| 473 | "onclick": function(){ |
| 474 | var g = dijit.byId("grid"); |
| 475 | if(g){ |
| 476 | var s1 = g.selection.selected, |
| 477 | s2 = g.selection.getSelected(); |
| 478 | console.log(s1.length, s1); |
| 479 | console.log(s2.length, s2); |
| 480 | } |
| 481 | } |
| 482 | })); |
| 483 | btns.appendChild(dojo.create("button",{ |
| 484 | "innerHTML": "resize", |
| 485 | "onclick": function(){ |
| 486 | var g = dijit.byId("grid"); |
| 487 | if(g){ |
| 488 | var cc = dojo.byId("gridContainer"); |
| 489 | dojo.style(cc, "height", (dojo.contentBox(cc).h + 10) + "px"); |
| 490 | dojo.style(cc, "width", (dojo.contentBox(cc).w - 10) + "px"); |
| 491 | g.resize(dojo.contentBox(cc)); |
| 492 | } |
| 493 | } |
| 494 | })); |
| 495 | var newID = 101; |
| 496 | btns.appendChild(dojo.create("button",{ |
| 497 | "innerHTML": "Add Item", |
| 498 | "onclick": function(){ |
| 499 | var g = dijit.byId("grid"); |
| 500 | g && g.store.newItem({ |
| 501 | "id": newID++, |
| 502 | "Heard": true, |
| 503 | "Checked": "True", |
| 504 | "Genre":"Easy Listening", |
| 505 | "Artist":"Bette Midler", |
| 506 | "Year":2003, |
| 507 | "Album":"Bette Midler Sings the Rosemary Clooney Songbook", |
| 508 | "Name":"Hey There", "Length":"03:31", |
| 509 | "Track":4, |
| 510 | "Composer":"Ross, Jerry 1926-1956 -w Adler, Richard 1921-", |
| 511 | "Download Date":"1923/4/9", |
| 512 | "Last Played":"04:32:49" |
| 513 | }); |
| 514 | } |
| 515 | })); |
| 516 | btns.appendChild(dojo.create("button",{ |
| 517 | "innerHTML": "New item and scroll to", |
| 518 | "onclick": function(){ |
| 519 | var g = dijit.byId("grid"); |
| 520 | if(g){ |
| 521 | var item = g.store.newItem({ |
| 522 | "id": newID++, |
| 523 | "Heard": true, |
| 524 | "Checked": "True", |
| 525 | "Genre":"Easy Listening", |
| 526 | "Artist":"Bette Midler", |
| 527 | "Year":2003, |
| 528 | "Album":"Bette Midler Sings the Rosemary Clooney Songbook", |
| 529 | "Name":"Hey There", "Length":"03:31", |
| 530 | "Track":4, |
| 531 | "Composer":"Ross, Jerry 1926-1956 -w Adler, Richard 1921-", |
| 532 | "Download Date":"1923/4/9", |
| 533 | "Last Played":"04:32:49" |
| 534 | }); |
| 535 | var rowCount = g.plugin('pagination') ? g.getTotalRowCount() : g.rowCount; |
| 536 | setTimeout(function(){g.scrollToRow(rowCount - 1);}, 600); |
| 537 | |
| 538 | } |
| 539 | } |
| 540 | })); |
| 541 | btns.appendChild(dojo.create("button",{ |
| 542 | "innerHTML": "Select All", |
| 543 | "onclick": function(){ |
| 544 | var g = dijit.byId("grid"); |
| 545 | if(g){ |
| 546 | var t1 = (new Date()).getTime(); |
| 547 | g.selection.selectRange(0, g.rowCount - 1); |
| 548 | console.log((new Date()).getTime() - t1); |
| 549 | } |
| 550 | } |
| 551 | })); |
| 552 | var toDisable = true; |
| 553 | btns.appendChild(dojo.create("button",{ |
| 554 | "innerHTML": "Disable 4th row selector", |
| 555 | "onclick": function(){ |
| 556 | var g = dijit.byId("grid"); |
| 557 | if(g){ |
| 558 | var cell = g.layout.cells[0]; |
| 559 | if(cell.setDisabled){ |
| 560 | cell.setDisabled(3, toDisable); |
| 561 | toDisable = !toDisable; |
| 562 | } |
| 563 | } |
| 564 | } |
| 565 | })); |
| 566 | btns.appendChild(dojo.create("button",{ |
| 567 | "innerHTML": "Select Unloaded", |
| 568 | "onclick": function(){ |
| 569 | var g = dijit.byId("grid"); |
| 570 | console.log(g); |
| 571 | if(g){ |
| 572 | g.selection.selectRange(60, 100); |
| 573 | } |
| 574 | } |
| 575 | })); |
| 576 | btns.appendChild(dojo.create("button",{ |
| 577 | "innerHTML": "clear sort", |
| 578 | "onclick": function(){ |
| 579 | var g = dijit.byId("grid"); |
| 580 | if(g){ |
| 581 | g.setSortIndex([]); |
| 582 | } |
| 583 | } |
| 584 | })); |
| 585 | |
| 586 | btns.appendChild(dojo.create("button",{ |
| 587 | "innerHTML": "show filter bar", |
| 588 | "onclick": function(){ |
| 589 | var g = dijit.byId("grid"); |
| 590 | if(g){ |
| 591 | g.showFilterBar(true, true); |
| 592 | } |
| 593 | } |
| 594 | })); |
| 595 | /*btns.appendChild(dojo.create("button",{ |
| 596 | "innerHTML": "dialog", |
| 597 | "onclick": testDialog |
| 598 | })); |
| 599 | btns.appendChild(dojo.create("button",{ |
| 600 | "innerHTML": "store", |
| 601 | "onclick": testStore |
| 602 | })); |
| 603 | btns.appendChild(dojo.create("button",{ |
| 604 | "innerHTML": "connect", |
| 605 | "onclick": testConnect |
| 606 | }));*/ |
| 607 | dojo.subscribe("test_repeat_grid_created", function(){ |
| 608 | setupSelectorTest(); |
| 609 | var g = dijit.byId("grid"); |
| 610 | g && g.setCookieEnabled && g.setCookieEnabled(false); |
| 611 | dojo.byId("enableGridCookieCB").checked = true; |
| 612 | dojo.byId("enableGridCWidthCookieCB").checked = false; |
| 613 | dojo.byId("enableGridSortCookieCB").checked = false; |
| 614 | dojo.byId("enableGridNSortCookieCB").checked = false; |
| 615 | dojo.byId("enableGridCOrderCookieCB").checked = false; |
| 616 | /*if(g.setFilter){ |
| 617 | g.setFilter([{ |
| 618 | type: "string", |
| 619 | column: 2, |
| 620 | value: "Buddy", |
| 621 | condition: "contains" |
| 622 | },{ |
| 623 | type: "string", |
| 624 | column: 2, |
| 625 | value: "King", |
| 626 | condition: "contains" |
| 627 | }], "logicany"); |
| 628 | }*/ |
| 629 | }); |
| 630 | var formTarget = new dojox.grid.enhanced.plugins.GridSource(dojo.byId("songForm"),{ |
| 631 | isSource: false |
| 632 | }); |
| 633 | dojo.connect(formTarget, "onDropGridRows", function(grid, rowIndexes){ |
| 634 | try{ |
| 635 | var s = grid.store, row = rowIndexes[0], item = grid.getItem(row); |
| 636 | console.log("item:", item); |
| 637 | dojo.attr(dojo.byId("inputName"), "value", s.getValue(item, "Name")); |
| 638 | dojo.attr(dojo.byId("inputAuthor"), "value", s.getValue(item, "Artist")); |
| 639 | dojo.attr(dojo.byId("inputAlbum"), "value", s.getValue(item, "Album")); |
| 640 | }catch(e){ |
| 641 | console.log("-----",e); |
| 642 | } |
| 643 | }); |
| 644 | }); |
| 645 | </script> |
| 646 | </head> |
| 647 | <body class="claro"> |
| 648 | <h1 class="title">dojox.grid.EnhancedGrid - plugins</h1> |
| 649 | <div id="ctrlBtns"></div><br/> |
| 650 | <div id="pluginList" dojoType="PluginTable" style="float:right;"></div> |
| 651 | <div id="gridContainer"></div><br/> |
| 652 | <div id="ctrlBtns2"></div><br/> |
| 653 | |
| 654 | <div id="menusSupport" style="display: none;"> |
| 655 | <div dojoType="dijit.Menu" id="headerMenu" style="display: none;"> |
| 656 | <div dojoType="dijit.MenuItem">Header Menu Item 1</div> |
| 657 | <div dojoType="dijit.MenuItem">Header Menu Item 2</div> |
| 658 | <div dojoType="dijit.MenuItem">Header Menu Item 3</div> |
| 659 | <div dojoType="dijit.MenuItem">Header Menu Item 4</div> |
| 660 | </div> |
| 661 | <div dojoType="dijit.Menu" id="rowMenu" style="display: none;"> |
| 662 | <div dojoType="dijit.MenuItem">Row Menu Item 1</div> |
| 663 | <div dojoType="dijit.MenuItem">Row Menu Item 2</div> |
| 664 | <div dojoType="dijit.MenuItem">Row Menu Item 3</div> |
| 665 | <div dojoType="dijit.MenuItem">Row Menu Item 4</div> |
| 666 | </div> |
| 667 | <div dojoType="dijit.Menu" id="cellMenu" style="display: none;"> |
| 668 | <div dojoType="dijit.MenuItem">Cell Menu Item 1</div> |
| 669 | <div dojoType="dijit.MenuItem">Cell Menu Item 2</div> |
| 670 | <div dojoType="dijit.MenuItem">Cell Menu Item 3</div> |
| 671 | <div dojoType="dijit.MenuItem">Cell Menu Item 4</div> |
| 672 | </div> |
| 673 | <div dojoType="dijit.Menu" id="selectedRegionMenu" style="display: none;"> |
| 674 | <div dojoType="dijit.MenuItem">Action 1 for Selected Region</div> |
| 675 | <div dojoType="dijit.MenuItem">Action 2 for Selected Region</div> |
| 676 | <div dojoType="dijit.MenuItem">Action 3 for Selected Region</div> |
| 677 | <div dojoType="dijit.MenuItem">Action 4 for Selected Region</div> |
| 678 | </div> |
| 679 | </div> |
| 680 | <div id="exporterSupport" class="supporter" style="display: none;"> |
| 681 | <input type='button' value='Export All to CSV' onclick='exportCSV()' /> |
| 682 | <input type='button' value='Export Selected to CSV' onclick='exportSelected()' /> |
| 683 | Separator is:<input id='sep' type='text' value=',' /> |
| 684 | Results:<br /> |
| 685 | <textarea rows="10" cols="100" id="csvResults"></textarea> |
| 686 | </div> |
| 687 | <div id="printerSupport" class="supporter" style="display: none;"> |
| 688 | <input type='button' value='Print All' onclick='printGrid()' /> |
| 689 | <input type='button' value='Print Selected' onclick='printSelected()' /> |
| 690 | <input type='button' value='Print Preview' onclick='printPreview()' /> |
| 691 | Use Title:<input id='print_title' type='text' value='Favorite Music' /> |
| 692 | </div> |
| 693 | <div id="cellMergeSupport" class="supporter" style="display: none;"> |
| 694 | <table> |
| 695 | <tr> |
| 696 | <td>At Row</td> |
| 697 | <td><input id="inputRow" type="text" value="3"/></td> |
| 698 | </tr> |
| 699 | <tr> |
| 700 | <td>From Column</td> |
| 701 | <td><input id="inputStart" type="text" value="1"/></td> |
| 702 | </tr> |
| 703 | <tr> |
| 704 | <td>To Column</td> |
| 705 | <td><input id="inputEnd" type="text" value="3"/></td> |
| 706 | </tr> |
| 707 | <tr> |
| 708 | <td>Use Value of Column</td> |
| 709 | <td><input id="inputMajor" type="text" value="2"/></td> |
| 710 | </tr> |
| 711 | <tr> |
| 712 | <td><button onclick="mergeCells()">Merge Cells</button></td> |
| 713 | </tr> |
| 714 | </table> |
| 715 | </div> |
| 716 | <div id="searchSupport" class="supporter" style="display: none;"> |
| 717 | Search all: Use "/.../" for Regular Expressions. Wildcards (* and ?) are available when not using "/.../". |
| 718 | <hr /> |
| 719 | <div>Search all columns for<input id="allcolumnsInput" type="text" size="30" value="/void/i" /> |
| 720 | <button onclick="onSearchAll(dojo.byId('allcolumnsInput').value)">Go =></button> |
| 721 | <span id="result1"></span> |
| 722 | </div> |
| 723 | <hr /> |
| 724 | Search with a query object (extends the functionality of the standard store query). |
| 725 | <table> |
| 726 | <thead> |
| 727 | <tr> |
| 728 | <th>Column</th> |
| 729 | <th>Query String or Regular Expression</th> |
| 730 | <th></th> |
| 731 | </tr> |
| 732 | </thead> |
| 733 | <tbody> |
| 734 | <tr> |
| 735 | <td>id</td> |
| 736 | <td><input name="id" class="searchInput" type="text" size="30" /></td> |
| 737 | <td rowspan="11" align="center" valign="center" style="padding-left: 50px;"> |
| 738 | <button onclick="onSearch()">Search =></button> |
| 739 | <span id="result2"></span> |
| 740 | </td> |
| 741 | </tr> |
| 742 | <tr> |
| 743 | <td>Genre</td> |
| 744 | <td><input name="Genre" class="searchInput" type="text" size="30" /></td> |
| 745 | </tr> |
| 746 | <tr> |
| 747 | <td>Artist</td> |
| 748 | <td><input name="Artist" class="searchInput" type="text" size="30" value="/an/i" /></td> |
| 749 | </tr> |
| 750 | <tr> |
| 751 | <td>Year</td> |
| 752 | <td><input name="Year" class="searchInput" type="text" size="30" /></td> |
| 753 | </tr> |
| 754 | <tr> |
| 755 | <td>Album</td> |
| 756 | <td><input name="Album" class="searchInput" type="text" size="30" value="/t.*t/i" /></td> |
| 757 | </tr> |
| 758 | <tr> |
| 759 | <td>Name</td> |
| 760 | <td><input name="Name" class="searchInput" type="text" size="30" /></td> |
| 761 | </tr> |
| 762 | <tr> |
| 763 | <td>Length</td> |
| 764 | <td><input name="Length" class="searchInput" type="text" size="30" /></td> |
| 765 | </tr> |
| 766 | <tr> |
| 767 | <td>Track</td> |
| 768 | <td><input name="Track" class="searchInput" type="text" size="30" /></td> |
| 769 | </tr> |
| 770 | <tr> |
| 771 | <td>Composer</td> |
| 772 | <td><input name="Composer" class="searchInput" type="text" size="30" value="*ss*" /></td> |
| 773 | </tr> |
| 774 | <tr> |
| 775 | <td>Download Date</td> |
| 776 | <td><input name="Download Date" class="searchInput" type="text" size="30" /></td> |
| 777 | </tr> |
| 778 | <tr> |
| 779 | <td>Last Played</td> |
| 780 | <td><input name="Last Played" class="searchInput" type="text" size="30" /></td> |
| 781 | </tr> |
| 782 | </tbody> |
| 783 | </table> |
| 784 | </div> |
| 785 | <div id="cookieSupport" class="supporter" style="display: none;"> |
| 786 | <p> |
| 787 | When destroying the grid... |
| 788 | </p> |
| 789 | <input id='enableGridCookieCB' type="checkbox" onchange="enableCookie(null, !this.checked)" />Do not persist anything<br /> |
| 790 | <input id='enableGridCWidthCookieCB' type="checkbox" onchange="enableCookie('cellWidths',!this.checked)" />Do not persist column width<br /> |
| 791 | <input id='enableGridSortCookieCB' type="checkbox" onchange="enableCookie('sortProps',!this.checked)" />Do not persist single sorting order<br /> |
| 792 | <input id='enableGridNSortCookieCB' type="checkbox" onchange="enableCookie('nestedSortProps',!this.checked)" />Do not persist nested sorting order<br /> |
| 793 | <input id='enableGridCOrderCookieCB' type="checkbox" onchange="enableCookie('columnOrder',!this.checked)" />Do not persist column arrangement<br /> |
| 794 | </div> |
| 795 | <div id="selectorSupport" class="supporter" style="display: none;"> |
| 796 | <div class="selectReport"> |
| 797 | <h2>Selected Cells: |
| 798 | Count: <input type="text" id="cellCnt" value="0"/> |
| 799 | </h2> |
| 800 | <textarea id="cells" rows="10" cols="40"></textarea> |
| 801 | </div> |
| 802 | <div class="selectReport"> |
| 803 | <h2>Selected Columns: |
| 804 | Count: <input type="text" id="colCnt" value="0"/> |
| 805 | </h2> |
| 806 | <textarea id="cols" rows="10" cols="40"></textarea> |
| 807 | </div> |
| 808 | <div class="selectReport"> |
| 809 | <h2>Selected Rows: |
| 810 | Count: <input type="text" id="rowCnt" value="0"/> |
| 811 | </h2> |
| 812 | <textarea id="rows" rows="10" cols="40"></textarea> |
| 813 | </div> |
| 814 | </div> |
| 815 | <div id="dndSupport" class="supporter" style="display:none; width: 40em;"> |
| 816 | <form id="songForm"> |
| 817 | <table> |
| 818 | <tr> |
| 819 | <td><label for="inputName">Song name</label></td> |
| 820 | <td><input id="inputName" type="text" /></td> |
| 821 | </tr> |
| 822 | <tr> |
| 823 | <td><label for="inputAuthor">Artist</label></td> |
| 824 | <td><input id="inputAuthor" type="text" /></td> |
| 825 | </tr> |
| 826 | <tr> |
| 827 | <td><label for="inputAlbum">Album</label></td> |
| 828 | <td><input id="inputAlbum" type="text" /></td> |
| 829 | </tr> |
| 830 | </table> |
| 831 | </form> |
| 832 | </div> |
| 833 | <div id="paginationSupport" class="supporter" style="display:none;"> |
| 834 | <table> |
| 835 | <tr> |
| 836 | <td><input id="inputScrollToRowIdx" type="text" /></td> |
| 837 | <td><button onclick="scrollToRow()">Scroll to row</button></td> |
| 838 | </tr> |
| 839 | <tr> |
| 840 | <td></td> |
| 841 | <td></td> |
| 842 | </tr> |
| 843 | <tr> |
| 844 | <td></td> |
| 845 | <td></td> |
| 846 | </tr> |
| 847 | <tr> |
| 848 | <td></td> |
| 849 | <td></td> |
| 850 | </tr> |
| 851 | </table> |
| 852 | </div> |
| 853 | <div class="tutor"> |
| 854 | <p> |
| 855 | <h2>How to use this page:</h2> |
| 856 | <ol> |
| 857 | <li>Select plugins/options at right side.</li> |
| 858 | <li>Press "Create" button.</li> |
| 859 | </ol> |
| 860 | </p> |
| 861 | <p> |
| 862 | <h2>Meaning of buttons:</h2> |
| 863 | <table> |
| 864 | <tr><td>Create</td><td>Create a grid using current plugins/options.</td></tr> |
| 865 | <tr><td>Destroy</td><td>Destroy the current grid.</td></tr> |
| 866 | <tr><td>Prev</td><td>Create a grid with previous layout</td></tr> |
| 867 | <tr><td>Next</td><td>Create a grid with next layout</td></tr> |
| 868 | <tr><td>Start</td><td>Keep creating and destorying grid (to test memory leak)</td></tr> |
| 869 | <tr><td>End</td><td>Stop the process that "Start" begins.</td></tr> |
| 870 | <tr><td>Select All</td><td>Select all plugins</td></tr> |
| 871 | <tr><td>Deselect All</td><td>Deselect all plugins</td></tr> |
| 872 | <tr><td>Refresh</td><td>Refresh the grid.</td></tr> |
| 873 | </table> |
| 874 | </p> |
| 875 | </div> |
| 876 | <div id="repeatcounter" style="float: left;"></div> |
| 877 | </body> |
| 878 | </html> |