| 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" |
| 2 | "http://www.w3.org/TR/html4/loose.dtd"> |
| 3 | <html> |
| 4 | <head> |
| 5 | <title>Test dojox.grid.DataGrid Programmatic Instantiation</title> |
| 6 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta> |
| 7 | <style type="text/css"> |
| 8 | @import "../../../dojo/resources/dojo.css"; |
| 9 | @import "../resources/Grid.css"; |
| 10 | @import "../resources/tundraGrid.css"; |
| 11 | |
| 12 | .heading { |
| 13 | font-weight: bold; |
| 14 | padding-bottom: 0.25em; |
| 15 | } |
| 16 | |
| 17 | #grid { |
| 18 | border: 1px solid #333; |
| 19 | width: 50em; |
| 20 | height: 30em; |
| 21 | } |
| 22 | </style> |
| 23 | <script type="text/javascript" src="../../../dojo/dojo.js" |
| 24 | data-dojo-config="isDebug:false, debugAtAllCosts: false, parseOnLoad: true"></script> |
| 25 | <script type="text/javascript"> |
| 26 | dojo.require("dijit.dijit"); // optimize: load dijit layer |
| 27 | dojo.require("dojox.grid.DataGrid"); |
| 28 | dojo.require("dojo.data.ItemFileWriteStore"); |
| 29 | dojo.require("dojo.parser"); |
| 30 | </script> |
| 31 | <script type="text/javascript" src="support/test_data.js"></script> |
| 32 | <script type="text/javascript"> |
| 33 | var grid = null; |
| 34 | var layout = [[ |
| 35 | {name: 'Column 1', field: 'col1'}, |
| 36 | {name: 'Column 2', field: 'col2'}, |
| 37 | {name: 'Column 3', field: 'col3'}, |
| 38 | {name: 'Column 4', field: 'col4', width: "150px"}, |
| 39 | {name: 'Column 5', field: 'col5'} |
| 40 | ],[ |
| 41 | {name: 'Column 6', field: 'col6'}, |
| 42 | {name: 'Column 7', field: 'col7'}, |
| 43 | {name: 'Column 8'}, |
| 44 | {name: 'Column 9', field: 'col3', colSpan: 2} |
| 45 | ]]; |
| 46 | |
| 47 | function toggleGrid() { |
| 48 | if (grid) { |
| 49 | grid.destroy(); |
| 50 | grid = null; |
| 51 | dojo.byId("toggleGridButton").innerHTML = "Create grid"; |
| 52 | } |
| 53 | else { |
| 54 | grid = new dojox.grid.DataGrid({ |
| 55 | id: "grid", |
| 56 | store: test_store, |
| 57 | structure: layout |
| 58 | }); |
| 59 | |
| 60 | dojo.byId("toggleGridButton").innerHTML = "Destroy grid"; |
| 61 | |
| 62 | dojo.byId("gridContainer").appendChild(grid.domNode); |
| 63 | grid.startup(); |
| 64 | } |
| 65 | } |
| 66 | </script> |
| 67 | </head> |
| 68 | <body class="tundra"> |
| 69 | <div class="heading">dojox.grid.DataGrid Programmatic Instantiation Test</div> |
| 70 | <button id="toggleGridButton" onClick="toggleGrid();">Create grid</button> |
| 71 | <div id="gridContainer"></div> |
| 72 | </body> |
| 73 | </html> |