| 1 |
(function(){ |
| 2 |
var gridIndex = 0; |
| 3 |
var totalCount = 1000; |
| 4 |
var timeInterval = 500; |
| 5 |
function createGrid(step){ |
| 6 |
try{ |
| 7 |
var g = dijit.byId("grid"); |
| 8 |
g && g.destroyRecursive(); |
| 9 |
dojo.publish("test_repeat_grid_destroyed"); |
| 10 |
for(gridIndex += step; gridIndex < 0; gridIndex += layout.length){} |
| 11 |
gridIndex %= layout.length; |
| 12 |
console.log("grid plugin args:", gridAttrs.plugins, gridIndex); |
| 13 |
var t1 = (new Date()).getTime(); |
| 14 |
g = new dojox.grid.EnhancedGrid(dojo.mixin({ |
| 15 |
"id": "grid", |
| 16 |
"store": test_store[0], |
| 17 |
"structure": layout[gridIndex] |
| 18 |
}, gridAttrs || {})); |
| 19 |
g.placeAt(dojo.byId("gridContainer")); |
| 20 |
g.startup(); |
| 21 |
dojo.byId("num").value = gridIndex; |
| 22 |
console.log(gridIndex + "---------------------------------------------------------------", (new Date()).getTime() - t1, "ms"); |
| 23 |
dojo.publish("test_repeat_grid_created"); |
| 24 |
return g; |
| 25 |
}catch(e){ |
| 26 |
console.log("createGrid:",e); |
| 27 |
} |
| 28 |
} |
| 29 |
var cnt = totalCount; |
| 30 |
function start(){ |
| 31 |
if(cnt > 0){ |
| 32 |
--cnt; |
| 33 |
createGrid(1); |
| 34 |
setTimeout(start, timeInterval); |
| 35 |
}else{ |
| 36 |
var g = dijit.byId("grid"); |
| 37 |
g && g.destroyRecursive(); |
| 38 |
cnt = totalCount; |
| 39 |
} |
| 40 |
} |
| 41 |
function stop(){ |
| 42 |
cnt = 0; |
| 43 |
} |
| 44 |
function gotoGrid(){ |
| 45 |
var id = parseInt(dojo.byId('num').value) % layout.length; |
| 46 |
gridIndex = isNaN(id) ? gridIndex : id; |
| 47 |
createGrid(0); |
| 48 |
} |
| 49 |
function destroy(){ |
| 50 |
var g = dijit.byId("grid"); |
| 51 |
g && g.destroyRecursive(); |
| 52 |
dojo.publish("test_repeat_grid_destroyed"); |
| 53 |
} |
| 54 |
dojo.addOnLoad(function(){ |
| 55 |
var btns = dojo.byId("ctrlBtns"); |
| 56 |
btns.appendChild(dojo.create("button",{ |
| 57 |
"innerHTML": "Play", |
| 58 |
"onclick": start |
| 59 |
})); |
| 60 |
btns.appendChild(dojo.create("button",{ |
| 61 |
"innerHTML": "Stop", |
| 62 |
"onclick": stop |
| 63 |
})); |
| 64 |
btns.appendChild(dojo.create("button",{ |
| 65 |
"innerHTML": "Prev", |
| 66 |
"onclick": dojo.partial(createGrid, -1) |
| 67 |
})); |
| 68 |
btns.appendChild(dojo.create("button",{ |
| 69 |
"innerHTML": "Next", |
| 70 |
"onclick": dojo.partial(createGrid, 1) |
| 71 |
})); |
| 72 |
btns.appendChild(dojo.create("input",{ |
| 73 |
"id": "num", |
| 74 |
"value": gridIndex, |
| 75 |
"type": "text" |
| 76 |
})); |
| 77 |
btns.appendChild(dojo.create("button",{ |
| 78 |
"innerHTML": "Create", |
| 79 |
"onclick": gotoGrid |
| 80 |
})); |
| 81 |
btns.appendChild(dojo.create("button",{ |
| 82 |
"innerHTML": "Destroy", |
| 83 |
"onclick": destroy |
| 84 |
})); |
| 85 |
|
| 86 |
}); |
| 87 |
})(); |