Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
110 lines (94 sloc) 2.31 KB
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1; IE=edge">
<title>Hypergrid - Example</title>
<script type="text/javascript" src="prototype.js"></script>
<script type="text/javascript" src="hypergrid.js"></script>
<link rel="stylesheet" type="text/css" href="hypergrid.css">
<script type="text/javascript">
/* TEST SCRIPT */
Event.observe(window, 'load', exampleBench);
function exampleBench() {
var grid = new Hypergrid({
// basic options
tableWidth : '100%',
multiSelect: true,
// column model
colModel: [
{
key : 'id',
innerHTML: 'ID',
width : 20
},
{
key : 'preview',
innerHTML: '',
width : 10,
style : { padding: 0 }
},
{
key : 'code',
innerHTML: 'code'
},
{
key : 'time',
innerHTML: 'time',
width : 80
}
],
// data rows
rows: (function _createRows() {
var rows = [];
for (var i = 0; i < 200; i++) {
var colorCode = '#' + Math.floor(Math.random() * 1000000000).toString(16).substr(0, 6);
rows.push({
cell: {
id: {
innerHTML: i.toString(10)
},
preview: {
style: {
boxShadow: 'inset 0 0 20px #fff',
background: colorCode
}
},
code: {
innerHTML: colorCode,
style: {
color: colorCode
}
},
time: {
innerHTML: new Date().getTime().toString(10)
}
}
});
}
return rows;
})(),
// for Benchmark
onRendered: function _onRendered() {
console.timeEnd('render');
},
// for Benchmark
onBeforeSort: function _onBeforeSort() {
console.time('render');
console.time('sort');
},
// for Benchmark
onSort: function _onBeforeSort() {
console.timeEnd('sort');
}
});
console.time('render');
grid.render('example-bench-container');
}
</script>
</head>
<body>
<div id="example-bench-container"></div>
</body>
</html>