forked from handsontable/handsontable
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
517 lines (414 loc) · 17.3 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
<!doctype html>
<html xmlns="http://www.w3.org/1999/html">
<head>
<meta charset='utf-8'>
<title>Handsontable - jQuery grid editor. Excel-like grid editing with HTML & JavaScript</title>
<!--
Loading handsontable dependencies.
Please note that some dependencies are optional:
- bootstrap-typeahead.js - is required only if you need the sexy autoexpanding textarea feature
- jquery.autoresize.js - is required only if you need the autocomplete feature
- jquery.contextMenu.js - is required only if you need the context menu feature
- jquery.contextMenu.css - is required only if you need the context menu feature
- jquery.ui.position.js - is required only if you need the context menu feature
-->
<script src="lib/jquery.js"></script>
<script src="jquery.handsontable.js"></script>
<script src="lib/bootstrap-typeahead.js"></script>
<script src="lib/jquery.autoresize.js"></script>
<script src="lib/jQuery-contextMenu/jquery.contextMenu.js"></script>
<script src="lib/jQuery-contextMenu/jquery.ui.position.js"></script>
<link rel="stylesheet" media="screen" href="lib/jQuery-contextMenu/jquery.contextMenu.css">
<link rel="stylesheet" media="screen" href="jquery.handsontable.css">
<!--
Loading demo dependencies. They are used here only to enhance the examples on this page
-->
<script src="demo/js/json2.min.js"></script>
<script src="demo/js/demo.js"></script>
<script src="demo/js/highlight/highlight.pack.js"></script>
<link rel="stylesheet" media="screen" href="demo/css/demo.css">
<link rel="stylesheet" media="screen" href="demo/js/highlight/styles/zenburn.css">
</head>
<body class="examplesListOffset">
<a href="http://github.com/warpech/jquery-handsontable"><img style="position: absolute; top: 0; right: 0; border: 0;" src="http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub"/></a>
<div id="container">
<h1><a href="index.html">Handsontable</a></h1>
<div class="description">
Handsontable is a minimalistic approach to Excel-like table editor in HTML & jQuery.
<strong>Now with column and row headers!</strong>
</div>
<h2 id="demos">Demos</h2>
<ul class="examplesList">
<li><a href="#example1">Autoexpanding
<div class="arr"></div>
</a></li>
<li><a href="#example2">Legend
<div class="arr"></div>
</a></li>
<li><a href="#example3">Autocomplete
<div class="arr"></div>
</a></li>
<li><a href="#example4">Scroll
<div class="arr"></div>
</a></li>
<li><a href="#example5">Drag-down
<div class="arr"></div>
</a></li>
<li><a href="#example7">Context menu
<div class="arr"></div>
</a></li>
<li><a href="#example6">Save
<div class="arr"></div>
</a></li>
<li><a href="#example8">Advanced demos
<div class="arr"></div>
</a></li>
</ul>
<div id="examples">
<a name="example1"></a>
<div id="example1container" class="example">
<div class="pad">
<h3>Autoexpanding</h3>
<p>Type in any cell and see how the grid adds new rows and cols automatically. You can try CTRL+Z and CTRL+Y to undo/redo.</p>
<p>Also, why not try <b>CTRL+C</b>, <b>CTRL+V</b> between this and Excel, Google Spreadsheet or LibreOffice!</p>
<div id="example1grid" class="dataTable"></div>
<p>Code:</p>
<pre class="html"><div id="example1grid" class="dataTable"></div>
<script>
$("#example1grid").handsontable({
rows: 5,
cols: 5,
minSpareCols: 1, //always keep at least 1 spare row at the right
minSpareRows: 1, //always keep at least 1 spare row at the bottom
contextMenu: true
});
var data = [
["", "Kia", "Nissan", "Toyota", "Honda"],
["2008", 10, 11, 12, 13],
["2009", 20, 11, 14, 13],
["2010", 30, 15, 12, 13]
];
$("#example1grid").handsontable("loadData", data);
</script></pre>
</div>
</div>
<a name="example2"></a>
<div id="example2container" class="example">
<div class="pad">
<h3>Legend</h3>
<p>The <b>legend</b> feature, which makes the first row have an
<span style="color: green; font-weight: bold">green</span> font.</p>
<p>In the below example, the <strong>column</strong> (A, B, C) and <strong>row</strong> (1, 2, 3) headers are on.
</p>
<div id="example2grid" class="dataTable"></div>
<p>Code:</p>
<pre class="html"><div id="example2grid" class="dataTable"></div>
<script>
$("#example2grid").handsontable({
rows: 5,
cols: 5,
rowHeaders: true,
colHeaders: true,
fillHandle: false, //fillHandle can be turned off
contextMenu: ["row_above", "row_below", "remove_row"],
//contextMenu will only allow inserting and removing rows
legend: [
{
match: function (row, col, data) {
return (row === 0); //if it is first row
},
style: {
color: 'green', //make the text green and bold
fontWeight: 'bold'
},
title: 'Heading' //make some tooltip
},
{
match: function (row, col, data) {
//if first row in this column contains word "Nissan"
return (row > 0 && data()[0][col].indexOf('Nissan') > -1);
},
style: {
fontStyle: 'italic' //make cells text in this column written in italic
}
}
]
});
var data = [
["", "Kia", "Nissan", "Toyota", "Honda"],
["2008", 10, 11, 12, 13],
["2009", 20, 11, 14, 13],
["2010", 30, 15, 12, 13]
];
$("#example2grid").handsontable("loadData", data);
</script></pre>
</div>
</div>
<a name="example3"></a>
<div id="example3container" class="example">
<div class="pad">
<h3>Autocomplete</h3>
<p>You can define rules for <b>autocompletition</b>. The below example will suggest you some colors as you type.</p>
<p>To keep this plugin lightweight, this feature has a dependency on another jQuery plugin:
<a href="https://github.com/twitter/bootstrap/blob/master/js/bootstrap-typeahead.js">bootstrap-typeahead</a>. It is included in the repo.
</p>
<div id="example3grid" class="dataTable"></div>
<p>Code:</p>
<pre class="html"><div id="example3grid" class="dataTable"></div>
<script>
$("#example3grid").handsontable({
rows: 7,
cols: 4,
rowHeaders: false, //turn off 1, 2, 3, ...
colHeaders: ["Car", "Year", "Chassis color", "Bumper color"],
legend: [
{
match: function (row, col, data) {
if (col == 0 || col == 2 || col == 3) {
return true;
}
return false;
},
style: {
fontStyle: 'italic' //make the text italic
},
title: "Type to show the list of options"
}
],
autoComplete: [
{
match: function (row, col, data) {
if (col == 2 || col == 3) {
return true;
}
return false;
},
highlighter: function (item) {
var query = this.query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&');
var label = item.replace(new RegExp('(' + query + ')', 'ig'), function ($1, match) {
return '<strong>' + match + '</strong>';
});
return '<span style="margin-right: 10px; background-color: ' + item + '">&nbsp;&nbsp;&nbsp;</span>' + label;
},
source: function () {
return ["yellow", "red", "orange", "green", "blue", "gray", "black", "white"]
}
},
{
match: function (row, col, data) {
return (col === 0); //if it is first column
},
source: function () {
return ["BMW", "Chrysler", "Nissan", "Suzuki", "Toyota", "Volvo"]
}
}
]
});
var data = [
["Nissan", 2009, "black", "black"],
["Nissan", 2006, "blue", "blue"],
["Chrysler", 2004, "yellow", "black"],
["Volvo", 2012, "white", "gray"]
];
$("#example3grid").handsontable("loadData", data);
</script></pre>
</div>
</div>
<a name="example4"></a>
<div id="example4container" class="example">
<div class="pad">
<h3>Scroll</h3>
<p>If you want scrollbars, just set it in the container CSS:</p>
<div id="example4grid" class="dataTable" style="width: 680px; height: 300px; overflow: scroll"></div>
<p>Code:</p>
<pre class="html"><div id="example4grid" class="dataTable" style="width: 680px;
height: 300px; overflow: scroll"></div>
<script>
$("#example4grid").handsontable({
rows: 40,
cols: 40,
rowHeaders: true,
colHeaders: true,
minSpareCols: 1, //always keep at least 1 spare row at the right
minSpareRows: 1 //always keep at least 1 spare row at the bottom
});
var data = [
["", "Kia", "Nissan", "Toyota", "Honda"],
["2008", 10, 11, 12, 13],
["2009", 20, 11, 14, 13],
["2010", 30, 15, 12, 13]
];
$("#example4grid").handsontable("loadData", data);
</script></pre>
</div>
</div>
<a name="example5"></a>
<div id="example5container" class="example">
<div class="pad">
<h3>Drag-down</h3>
<p>Notice the little square (<b>fill handle</b>) in the corner of the selected cell. You can drag it (drag-down) to repeat the values from the cell.
</p>
<p>Double click the fill handle to fill the selection down to the last row.</p>
<div id="example5grid" class="dataTable"></div>
<p>Code:</p>
<pre class="html"><div id="example5grid" class="dataTable"></div>
<script>
$("#example5grid").handsontable({
rows: 8,
cols: 8,
rowHeaders: true,
colHeaders: true,
minSpareCols: 1,
minSpareRows: 1,
fillHandle: true //possible values: true, false, "horizontal", "vertical"
});
var data = [
["", "Kia", "Nissan", "Toyota", "Honda"],
["2008", 10, 11, 12, 13],
["2009", 20, 11, 14, 13],
["2010", 30, 15, 12, 13]
];
$("#example5grid").handsontable("loadData", data);
</script></pre>
</div>
</div>
<a name="example7"></a>
<div id="example7container" class="example">
<div class="pad">
<h3>Context menu</h3>
<p>Right click to see the context menu.</p>
<div id="example7grid" class="dataTable"></div>
<p>Code:</p>
<pre class="html"><div id="example7grid" class="dataTable"></div>
<script>
$("#example7grid").handsontable({
rows: 5,
cols: 5,
rowHeaders: true,
colHeaders: true,
minSpareCols: 1,
minSpareRows: 1,
contextMenu: true
});
var data = [
["", "Kia", "Nissan", "Toyota", "Honda"],
["2008", 10, 11, 12, 13],
["2009", 20, 11, 14, 13],
["2010", 30, 15, 12, 13]
];
$("#example7grid").handsontable("loadData", data);
</script></pre>
</div>
</div>
<a name="example6"></a>
<div id="example6container" class="example">
<div class="pad">
<h3>Save</h3>
<p>Use the
<b>onChange</b> callback to track changes made in the table. In the example below it is used to display the last changes.
</p>
<p>There is also the NEW
<b>onBeforeChange</b> callback, which can be used to validate changes before they are applied to the table.</p>
<div id="example6grid" class="dataTable"></div>
<p>Callback console: <span class="code">[[row, col, oldValue, newValue], ...]</span></p>
<pre id="example6console" class="console">Edit the above grid to see callback</pre>
<p>Code:</p>
<pre class="html"><div id="example6grid" class="dataTable"></div>
<pre id="example6console" class="console">
Edit the above grid to see callback
</pre>
<script>
var first = true;
$("#example6grid").handsontable({
rows: 8,
cols: 8,
rowHeaders: true,
colHeaders: true,
minSpareCols: 1,
minSpareRows: 1,
contextMenu: true,
onBeforeChange: function (data) {
for (var i = 0, ilen = data.length; i < ilen; i++) {
if (data[i][3] === "foo") {
//gently don't accept the word "foo"
data[i][3] = false;
}
else if (data[i][3] === "bar") {
//if the word bar is given, add a ! at the end of it
data[i][3] = data[i][3] + '!';
}
else if (data[i][3] === "nuke") {
//if any of pasted cells contains the word "nuke", reject the whole paste
return false;
}
}
},
onChange: function (data) {
if (first) {
first = false;
return; //don't show this change in console
}
$("#example6console").text(JSON.stringify(data));
}
});
var data = [
["", "Kia", "Nissan", "Toyota", "Honda"],
["2008", 10, 11, 12, 13],
["2009", 20, 11, 14, 13],
["2010", 30, 15, 12, 13]
];
$("#example6grid").handsontable("loadData", data);
</script></pre>
</div>
</div>
<a name="example8"></a>
<div id="example8container" class="example">
<div class="pad" style="height: 300px;">
<h3>Advanced demos</h3>
<p>Check out some advanced usage examples:</p>
<ul>
<li><a href="demo/buttons.html">Custom buttons</a></li>
<li><a href="demo/conditional.html">Conditional formatting</a></li>
<li><a href="demo/prepopulate.html">Pre-populate new rows from template</a></li>
</ul>
</div>
</div>
</div>
<h2>Documentation</h2>
<p>
Available plugin methods and configuration options are listed in
<a href="http://github.com/warpech/jquery-handsontable">README.md on GitHub</a>
</p>
<h2>Download</h2>
<p>
You can download this project in either
<a href="http://github.com/warpech/jquery-handsontable/zipball/master">zip</a> or
<a href="http://github.com/warpech/jquery-handsontable/tarball/master">tar</a> formats.
</p>
<p>
You can also clone the project with <a href="http://git-scm.com">Git</a>
by running:
</p>
<pre class="console">$ git clone git://github.com/warpech/jquery-handsontable</pre>
<h2>License</h2>
<p>
Licensed under the MIT license
</p>
<h2>Donate</h2>
<p>
If you like Handsontable and you would like to support the development of new features, please consider a donation. Thanks!
</p>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----MIIHPwYJKoZIhvcNAQcEoIIHMDCCBywCAQExggEwMIIBLAIBADCBlDCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb20CAQAwDQYJKoZIhvcNAQEBBQAEgYC2RAEbSNLyCiqsV8IVaJDSfNHbKrbgbtySofYZafN+PgzMUscck06eq+t9+Eob0nLC73tyAwll4OkSBtSRD5UKIWYWB89+83ziEVK8Fqqr6t9+cCm2il4xVZ/P3no7r22NRChQ4U3dpKB7s0kbRY3mRoNEsXGwuEP31tntd4iJrTELMAkGBSsOAwIaBQAwgbwGCSqGSIb3DQEHATAUBggqh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1UEBxMNTW91bnRhaW4gVmlldzEUMBIGA1UEChMLUGF5UGFsIEluYy4xEzARBgNVBAsUCmxpdmVfY2VydHMxETAPBgNVBAMUCGxpdmVfYXBpMRwwGgYJKoZIhvcNAQkBFg1yZUBwYXlwYWwuY29tggEAMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADgYEAgV86VpqAWuXvX6Oro4qJ1tYVIT5DgWpE692Ag422H7yRIr/9j/iKG4Thia/Oflx4TdL+IFJBAyPK9v6zZNZtBgPBynXb048hsP16l2vi0k5Q2JKiPDsEfBhGI+HnxLXEaUWAcVfCsQFvd2A1sxRr67ip5y2wwBelUecP3AjJ+YcxggGaMIIBlgIBATCBlDCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb20CAQAwCQYFKw4DAhoFAKBdMBgGCSqGSIb3DQEJAzELBgkqhkiG9w0BBwEwHAYJKoZIhvcNAQkFMQ8XDTEyMDcxMTEzMjY1NVowIwYJKoZIhvcNAQkEMRYEFOqptKi/U28rpE9UTgVFkuY3Ad5fMA0GCSqGSIb3DQEBAQUABIGAhUWgC6Vtu1UsBYWfARwblzMH43hTJpthE4NvbYyhJnEQ9/k+sptfKm544G3kjKsIIYk9K05KIjWfe2evPnsO2CVux38hP7bEbKL+RsJ6GugVwjPr3ZoJiaxwt43Tllfyb+ZRtlyPEcQCIjtJKZpcTy0IKLQ+IuMNPLY3m978m0I=-----END PKCS7-----
">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/pl_PL/i/scr/pixel.gif" width="1" height="1">
</form>
<h2>Authors</h2>
<p>
Marcin Warpechowski / <a href="http://www.giraffeapp.com/">Giraffe</a>
</p>
</div>
</body>
</html>