| 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>EnhancedGrid Memory Leak Test - Great/Destroy</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.form.CheckBox"); |
| 55 | dojo.require("dijit.form.DateTextBox"); |
| 56 | dojo.require("dijit._WidgetsInTemplateMixin"); |
| 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 | plugins: {} |
| 82 | }; |
| 83 | </script> |
| 84 | <script type="text/javascript" src="support/test_write_store_music.js"></script> |
| 85 | <script type="text/javascript" src="support/test_layout_music.js"></script> |
| 86 | <script type="text/javascript" src="support/test_repeat.js"></script> |
| 87 | <script type="text/javascript"> |
| 88 | var plugins = { |
| 89 | "nestedSorting": {}, |
| 90 | "indirectSelection": { |
| 91 | headerSelector: true |
| 92 | }, |
| 93 | "menus": { |
| 94 | headerMenu: "headerMenu", |
| 95 | rowMenu: "rowMenu", |
| 96 | cellMenu: "cellMenu", |
| 97 | selectedRegionMenu: "selectedRegionMenu" |
| 98 | }, |
| 99 | "exporter": {}, |
| 100 | "printer": {}, |
| 101 | "filter": { |
| 102 | closeFilterbarButton: true, |
| 103 | ruleCount: 0 |
| 104 | }, |
| 105 | "cookie": {}, |
| 106 | "selector": { |
| 107 | col: false |
| 108 | }, |
| 109 | "dnd": { |
| 110 | copyOnly: false |
| 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 setupSelectorTest(){ |
| 228 | var grid = dijit.byId("grid"), |
| 229 | func = function(type, start, end, selected){ |
| 230 | fill("col", selected["col"]); |
| 231 | fill("row", selected["row"]); |
| 232 | fill("cell", selected["cell"]); |
| 233 | }, |
| 234 | fill = function(type, selected){ |
| 235 | var getString; |
| 236 | var cells = grid.layout.cells; |
| 237 | switch(type){ |
| 238 | case "col": |
| 239 | getString = function(item){ |
| 240 | return "Column " + item.col + ": " + dojo.toJson(item.except); |
| 241 | } |
| 242 | break; |
| 243 | case "row": |
| 244 | getString = function(item){ |
| 245 | return "Row " + item.row + ": " + dojo.toJson(item.except); |
| 246 | } |
| 247 | break; |
| 248 | case "cell": |
| 249 | getString = function(item){ |
| 250 | return "Cell " + item.row + " , " + item.col; |
| 251 | } |
| 252 | } |
| 253 | }; |
| 254 | } |
| 255 | dojo.addOnLoad(function(){ |
| 256 | dojo.subscribe("test_repeat_grid_created", function(){ |
| 257 | var g = dijit.byId("grid"); |
| 258 | g && g.setCookieEnabled && g.setCookieEnabled(false); |
| 259 | }); |
| 260 | }); |
| 261 | </script> |
| 262 | </head> |
| 263 | <body class="claro"> |
| 264 | <h1 class="title">EnhancedGrid Memory Leak Test - Great/Destroy</h1> |
| 265 | <h2><p>Repeat creating/destroying Grid instances:</p></h2> |
| 266 | <div id="ctrlBtns"></div><br/> |
| 267 | <div id="pluginList" dojoType="PluginTable" style="float:right;"></div> |
| 268 | <div id="gridContainer"></div><br/> |
| 269 | <div id="ctrlBtns2"></div><br/> |
| 270 | <div id="menusSupport" style="display: none;"> |
| 271 | <div dojoType="dijit.Menu" id="headerMenu" style="display: none;"> |
| 272 | <div dojoType="dijit.MenuItem">Header Menu Item 1</div> |
| 273 | <div dojoType="dijit.MenuItem">Header Menu Item 2</div> |
| 274 | <div dojoType="dijit.MenuItem">Header Menu Item 3</div> |
| 275 | <div dojoType="dijit.MenuItem">Header Menu Item 4</div> |
| 276 | </div> |
| 277 | <div dojoType="dijit.Menu" id="rowMenu" style="display: none;"> |
| 278 | <div dojoType="dijit.MenuItem">Row Menu Item 1</div> |
| 279 | <div dojoType="dijit.MenuItem">Row Menu Item 2</div> |
| 280 | <div dojoType="dijit.MenuItem">Row Menu Item 3</div> |
| 281 | <div dojoType="dijit.MenuItem">Row Menu Item 4</div> |
| 282 | </div> |
| 283 | <div dojoType="dijit.Menu" id="cellMenu" style="display: none;"> |
| 284 | <div dojoType="dijit.MenuItem">Cell Menu Item 1</div> |
| 285 | <div dojoType="dijit.MenuItem">Cell Menu Item 2</div> |
| 286 | <div dojoType="dijit.MenuItem">Cell Menu Item 3</div> |
| 287 | <div dojoType="dijit.MenuItem">Cell Menu Item 4</div> |
| 288 | </div> |
| 289 | <div dojoType="dijit.Menu" id="selectedRegionMenu" style="display: none;"> |
| 290 | <div dojoType="dijit.MenuItem">Action 1 for Selected Region</div> |
| 291 | <div dojoType="dijit.MenuItem">Action 2 for Selected Region</div> |
| 292 | <div dojoType="dijit.MenuItem">Action 3 for Selected Region</div> |
| 293 | <div dojoType="dijit.MenuItem">Action 4 for Selected Region</div> |
| 294 | </div> |
| 295 | </div> |
| 296 | </body> |
| 297 | </html> |