|
| 1 | +<!doctype html> |
| 2 | +<head> |
| 3 | + <title></title> |
| 4 | + <link rel="stylesheet" href="{{ urls.style }}"> |
| 5 | + <script src="{{ urls.script }}"></script> |
| 6 | + <script src="/js/test-runner.js"></script> |
| 7 | + <style> |
| 8 | + #example { |
| 9 | + width: 1250px; |
| 10 | + height: 800px; |
| 11 | + overflow: hidden; |
| 12 | + } |
| 13 | + .currentRow, .currentCol { |
| 14 | + background-color: #ccc !important; |
| 15 | + } |
| 16 | + </style> |
| 17 | +</head> |
| 18 | +<html> |
| 19 | +<body> |
| 20 | + |
| 21 | +<div id="example"></div> |
| 22 | +<script> |
| 23 | + Handsontable.renderers.registerRenderer('flagRenderer', function (instance, td, row, col, prop, value, cellProperties) { |
| 24 | + var currencyCode = value; |
| 25 | + |
| 26 | + while (td.firstChild) { |
| 27 | + td.removeChild(td.firstChild); |
| 28 | + } |
| 29 | + var flagElement = document.createElement('DIV'); |
| 30 | + |
| 31 | + flagElement.className = 'flag ' + currencyCode; |
| 32 | + flagElement.textContent = '[flag]-' + value; |
| 33 | + td.appendChild(flagElement); |
| 34 | + }); |
| 35 | + Handsontable.renderers.registerRenderer('firstRowRenderer', function (instance, td, row, col, prop, value, cellProperties) { |
| 36 | + Handsontable.renderers.TextRenderer.apply(this, arguments); |
| 37 | + td.style.fontWeight = 'bold'; |
| 38 | + td.style.color = 'green'; |
| 39 | + td.style.background = '#CEC'; |
| 40 | + }); |
| 41 | + Handsontable.renderers.registerRenderer('firstColRenderer', function (instance, td, row, col, prop, value, cellProperties) { |
| 42 | + Handsontable.renderers.TextRenderer.apply(this, arguments); |
| 43 | + td.style.fontWeight = 'bold'; |
| 44 | + td.style.color = 'red'; |
| 45 | + td.style.background = '#eecccc'; |
| 46 | + }); |
| 47 | + var columns = []; |
| 48 | + var baseColumns = [ |
| 49 | + { |
| 50 | + type: 'numeric', |
| 51 | + width: 40, |
| 52 | + }, |
| 53 | + { |
| 54 | + renderer: 'flagRenderer' |
| 55 | + }, |
| 56 | + { type: 'text' }, |
| 57 | + { type: 'text' }, |
| 58 | + { type: 'text' }, |
| 59 | + { type: 'text', width: 100, }, |
| 60 | + { type: 'text' }, |
| 61 | + { type: 'text' }, |
| 62 | + { type: 'text' }, |
| 63 | + { type: 'text' }, |
| 64 | + { type: 'text', width: 150, }, |
| 65 | + { |
| 66 | + type: 'numeric', |
| 67 | + numericFormat: { |
| 68 | + pattern: '0.0000' |
| 69 | + } |
| 70 | + }, |
| 71 | + { |
| 72 | + type: 'date', |
| 73 | + dateFormat: 'MM/DD/YYYY' |
| 74 | + }, |
| 75 | + { |
| 76 | + type: 'numeric', |
| 77 | + numericFormat: { |
| 78 | + pattern: '0.00%' |
| 79 | + }, |
| 80 | + width: 90, |
| 81 | + }, |
| 82 | + { |
| 83 | + type: 'autocomplete', |
| 84 | + }, |
| 85 | + { |
| 86 | + type: 'dropdown', |
| 87 | + }, |
| 88 | + ]; |
| 89 | + |
| 90 | + for (var i = 0; i < 1000; i++) { |
| 91 | + columns.push(JSON.parse(JSON.stringify(baseColumns[i % (baseColumns.length)]))); |
| 92 | + } |
| 93 | + |
| 94 | + var hot = new Handsontable(example, { |
| 95 | + licenseKey: 'non-commercial-and-evaluation', |
| 96 | + // data: Handsontable.helper.createSpreadsheetData(10000, 100), |
| 97 | + data: Handsontable.helper.createSpreadsheetData(1000, 100), |
| 98 | + // columns: columns, |
| 99 | + rowHeaders: true, |
| 100 | + colHeaders: true, |
| 101 | + currentRowClassName: 'currentRow', |
| 102 | + currentColClassName: 'currentCol', |
| 103 | + // colWidths: 30, |
| 104 | + viewportRowRenderingOffset: 0, |
| 105 | + viewportColumnRenderingOffset: 0, |
| 106 | + afterModifyTransformStart: function(coords, rowTransformDir, colTransformDir) { |
| 107 | + if (rowTransformDir === -1) { |
| 108 | + coords.col = coords.col + 20; |
| 109 | + } |
| 110 | + if (rowTransformDir === 1) { |
| 111 | + coords.col = coords.col - 20; |
| 112 | + } |
| 113 | + }, |
| 114 | + fixedColumnsLeft: 2, |
| 115 | + fixedRowsTop: 2, |
| 116 | + cells: function(row, col) { |
| 117 | + var cellProperties = {}; |
| 118 | + var data = this.instance.getDataAtCell(row, col); |
| 119 | + |
| 120 | + if (row === 0 || data === 'readOnly') { |
| 121 | + cellProperties.readOnly = true; |
| 122 | + } |
| 123 | + if (row === 0 || row === 1) { |
| 124 | + cellProperties.renderer = 'firstRowRenderer'; |
| 125 | + } |
| 126 | + if (col === 0 || col === 1) { |
| 127 | + cellProperties.renderer = 'firstColRenderer'; |
| 128 | + } |
| 129 | + |
| 130 | + if (row === 0 && col === 0) { |
| 131 | + cellProperties.className = 'htRight'; |
| 132 | + } |
| 133 | + if (row === 1 && col === 1) { |
| 134 | + cellProperties.className = 'htRight'; |
| 135 | + } |
| 136 | + if (row === 3 && col === 4) { |
| 137 | + cellProperties.className = 'htRight'; |
| 138 | + } |
| 139 | + |
| 140 | + return cellProperties; |
| 141 | + }, |
| 142 | + renderer: function(instance, TD, row, col, prop, value, cellProperties) { |
| 143 | + Handsontable.renderers.BaseRenderer.call(this, instance, TD, row, col, prop, value, cellProperties); |
| 144 | + |
| 145 | + value = row % 2 ? value : (value + '<b>' + value.substr(0, 2) + '</b>'); |
| 146 | + |
| 147 | + TD.innerHTML = value; |
| 148 | + TD.setAttribute('id-row', row); |
| 149 | + TD.setAttribute('id-col', col); |
| 150 | + TD.setAttribute('id-prop', prop); |
| 151 | + TD.classList.add('class-' + row); |
| 152 | + TD.style.color = '#999'; |
| 153 | + }, |
| 154 | + // renderer: function(instance, TD, row, col, prop, value, cellProperties) { |
| 155 | + // TD.classList.add('test-class'); |
| 156 | + // TD.innerHTML = '.<b>' + value + '</b>'; |
| 157 | + // }, |
| 158 | + // autoColumnSize: true, // AutoColumnSize is asynchronous so it has to be disabled to not inferred stat results |
| 159 | + }); |
| 160 | +</script> |
| 161 | +<script>document.writeln('Build date: ' + Handsontable.buildDate + ', version: ' + Handsontable.version)</script> |
| 162 | +<script> |
| 163 | + setTimeout(function() { |
| 164 | + document.title = 'ready'; // Mark that the runner page is ready to tests |
| 165 | + }, 2000); |
| 166 | +</script> |
| 167 | +</body> |
| 168 | +</html> |
0 commit comments