1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
4 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
5 <link rel="shortcut icon" type="image/ico" href="http://www.sprymedia.co.uk/media/images/favicon.ico" />
7 <title>KeyTables editing example</title>
8 <style type="text/css" title="currentStyle">
9 @import "../../media/css/demo_page.css";
10 @import "../../media/css/demo_table.css";
12 <script type="text/javascript" charset="utf-8" src="../../media/js/jquery.js"></script>
13 <script type="text/javascript" charset="utf-8" src="../../examples/examples_support/jquery.jeditable.js"></script>
14 <script type="text/javascript" charset="utf-8" src="js/KeyTable.js"></script>
15 <script type="text/javascript" charset="utf-8">
16 $(document).ready( function () {
17 var keys = new KeyTable( {
18 "table": document.getElementById('example')
21 /* Apply a return key event to each cell in the table */
22 keys.event.action( null, null, function (nCell) {
23 /* Block KeyTable from performing any events while jEditable is in edit mode */
26 /* Initialise the Editable instance for this table */
27 $(nCell).editable( function (sVal) {
28 /* Submit function (local only) - unblock KeyTable */
30 $(nCell).editable('destroy');
34 "onreset": function(){
35 /* Unblock KeyTable, but only after this 'esc' key event has finished. Otherwise
36 * it will 'esc' KeyTable as well
38 $(nCell).editable('destroy');
39 setTimeout( function () {keys.block = false;}, 0);
43 /* Dispatch click event to go into edit mode - Saf 4 needs a timeout... */
44 setTimeout( function () { $(nCell).click(); }, 0 );
49 <body id="dt_example">
51 <div class="full_width big">
52 KeyTable editing example
56 <p>Possibly one of the most obvious applications of KeyTable is using it to navigate around a table, allowing a user to edit data as they go. This is an example of how that might be done through integration with the excellent <a href="http://www.appelsiini.net/projects/jeditable">jEditable</a> plug-in for jQuery.</p>
57 <p>To edit data in the table, simply navigate to where you want to edit using the arrow keys, hit return and they make your edit. Hit return again to complete and submit the edit (note this example doesn't actually send the data to the server!) and then continue navigating.</p>
61 <table cellpadding="0" cellspacing="0" border="0" class="display KeyTable" id="example">
64 <th>Rendering engine</th>
67 <th>Engine version</th>
74 <td>Internet Explorer 4.0</td>
76 <td class="center">4</td>
77 <td class="center">X</td>
81 <td>Internet Explorer 5.0</td>
83 <td class="center">5</td>
84 <td class="center">C</td>
88 <td>Internet Explorer 5.5</td>
90 <td class="center">5.5</td>
91 <td class="center">A</td>
95 <td>Internet Explorer 6</td>
97 <td class="center">6</td>
98 <td class="center">A</td>
102 <td>Internet Explorer 7</td>
104 <td class="center">7</td>
105 <td class="center">A</td>
109 <td>AOL browser (AOL desktop)</td>
111 <td class="center">6</td>
112 <td class="center">A</td>
117 <td>Win 98+ / OSX.2+</td>
118 <td class="center">1.7</td>
119 <td class="center">A</td>
124 <td>Win 98+ / OSX.2+</td>
125 <td class="center">1.8</td>
126 <td class="center">A</td>
131 <td>Win 98+ / OSX.2+</td>
132 <td class="center">1.8</td>
133 <td class="center">A</td>
138 <td>Win 2k+ / OSX.3+</td>
139 <td class="center">1.9</td>
140 <td class="center">A</td>
146 <td class="center">1.8</td>
147 <td class="center">A</td>
153 <td class="center">1.8</td>
154 <td class="center">A</td>
158 <td>Netscape 7.2</td>
159 <td>Win 95+ / Mac OS 8.6-9.2</td>
160 <td class="center">1.7</td>
161 <td class="center">A</td>
165 <td>Netscape Browser 8</td>
167 <td class="center">1.7</td>
168 <td class="center">A</td>
172 <td>Netscape Navigator 9</td>
173 <td>Win 98+ / OSX.2+</td>
174 <td class="center">1.8</td>
175 <td class="center">A</td>
180 <td>Win 95+ / OSX.1+</td>
181 <td class="center">1</td>
182 <td class="center">A</td>
187 <td>Win 95+ / OSX.1+</td>
188 <td class="center">1.1</td>
189 <td class="center">A</td>
194 <td>Win 95+ / OSX.1+</td>
195 <td class="center">1.2</td>
196 <td class="center">A</td>
201 <td>Win 95+ / OSX.1+</td>
202 <td class="center">1.3</td>
203 <td class="center">A</td>
208 <td>Win 95+ / OSX.1+</td>
209 <td class="center">1.4</td>
210 <td class="center">A</td>
215 <td>Win 95+ / OSX.1+</td>
216 <td class="center">1.5</td>
217 <td class="center">A</td>
222 <td>Win 95+ / OSX.1+</td>
223 <td class="center">1.6</td>
224 <td class="center">A</td>
229 <td>Win 98+ / OSX.1+</td>
230 <td class="center">1.7</td>
231 <td class="center">A</td>
236 <td>Win 98+ / OSX.1+</td>
237 <td class="center">1.8</td>
238 <td class="center">A</td>
242 <td>Seamonkey 1.1</td>
243 <td>Win 98+ / OSX.2+</td>
244 <td class="center">1.8</td>
245 <td class="center">A</td>
249 <td>Epiphany 2.20</td>
251 <td class="center">1.8</td>
252 <td class="center">A</td>
258 <td class="center">125.5</td>
259 <td class="center">A</td>
265 <td class="center">312.8</td>
266 <td class="center">A</td>
272 <td class="center">419.3</td>
273 <td class="center">A</td>
279 <td class="center">522.1</td>
280 <td class="center">A</td>
286 <td class="center">420</td>
287 <td class="center">A</td>
291 <td>iPod Touch / iPhone</td>
293 <td class="center">420.1</td>
294 <td class="center">A</td>
300 <td class="center">413</td>
301 <td class="center">A</td>
306 <td>Win 95+ / OSX.1+</td>
307 <td class="center">-</td>
308 <td class="center">A</td>
313 <td>Win 95+ / OSX.2+</td>
314 <td class="center">-</td>
315 <td class="center">A</td>
320 <td>Win 95+ / OSX.2+</td>
321 <td class="center">-</td>
322 <td class="center">A</td>
327 <td>Win 95+ / OSX.2+</td>
328 <td class="center">-</td>
329 <td class="center">A</td>
334 <td>Win 95+ / OSX.3+</td>
335 <td class="center">-</td>
336 <td class="center">A</td>
341 <td>Win 88+ / OSX.3+</td>
342 <td class="center">-</td>
343 <td class="center">A</td>
348 <td>Win 88+ / OSX.3+</td>
349 <td class="center">-</td>
350 <td class="center">A</td>
354 <td>Opera for Wii</td>
356 <td class="center">-</td>
357 <td class="center">A</td>
363 <td class="center">-</td>
364 <td class="center">A</td>
368 <td>Nintendo DS browser</td>
370 <td class="center">8.5</td>
371 <td class="center">C/A<sup>1</sup></td>
375 <td>Konqureror 3.1</td>
377 <td class="center">3.1</td>
378 <td class="center">C</td>
382 <td>Konqureror 3.3</td>
384 <td class="center">3.3</td>
385 <td class="center">A</td>
389 <td>Konqureror 3.5</td>
391 <td class="center">3.5</td>
392 <td class="center">A</td>
396 <td>Internet Explorer 4.5</td>
398 <td class="center">-</td>
399 <td class="center">X</td>
403 <td>Internet Explorer 5.1</td>
404 <td>Mac OS 7.6-9</td>
405 <td class="center">1</td>
406 <td class="center">C</td>
410 <td>Internet Explorer 5.2</td>
412 <td class="center">1</td>
413 <td class="center">C</td>
417 <td>NetFront 3.1</td>
418 <td>Embedded devices</td>
419 <td class="center">-</td>
420 <td class="center">C</td>
424 <td>NetFront 3.4</td>
425 <td>Embedded devices</td>
426 <td class="center">-</td>
427 <td class="center">A</td>
432 <td>Embedded devices</td>
433 <td class="center">-</td>
434 <td class="center">X</td>
440 <td class="center">-</td>
441 <td class="center">X</td>
447 <td class="center">-</td>
448 <td class="center">X</td>
453 <td>Windows Mobile 6</td>
454 <td class="center">-</td>
455 <td class="center">C</td>
461 <td class="center">-</td>
462 <td class="center">C</td>
465 <td>Other browsers</td>
468 <td class="center">-</td>
469 <td class="center">U</td>
474 <th>Rendering engine</th>
477 <th>Engine version</th>
483 <div class="spacer"></div>
486 <h1>Initialisation code</h1>
487 <pre>$(document).ready( function () {
488 var keys = new KeyTable( {
489 "table": document.getElementById('example')
492 /* Apply a return key event to each cell in the table */
493 keys.event.action( null, null, function (nCell) {
494 /* Block KeyTable from performing any events while jEditable is in edit mode */
497 /* Initialise the Editable instance for this table */
498 $(nCell).editable( function (sVal) {
499 /* Submit function (local only) - unblock KeyTable */
504 "onreset": function(){
505 /* Unblock KeyTable, but only after this 'esc' key event has finished. Otherwise
506 * it will 'esc' KeyTable as well
508 setTimeout( function () {keys.block = false;}, 0);
512 /* Dispatch click event to go into edit mode - Saf 4 needs a timeout... */
513 setTimeout( function () { $(nCell).click(); }, 0 );
518 <h1>Other examples</h1>
520 <li><a href="index.html">Basic usage</a></li>
521 <li><a href="editing.html">Editing a table</a></li>
522 <li><a href="form.html">Integration with an HTML form</a></li>
523 <li><a href="datatable.html">Integration with DataTables</a></li>
524 <li><a href="datatable_scrolling.html">Using KeyTable with scrolling in DataTables</a></li>
529 <div id="footer" style="text-align:center;">
530 <span style="font-size:10px;">
531 KeyTable © Allan Jardine 2009.<br>
532 Information in the table © <a href="http://www.u4eatech.com">U4EA Technologies</a> 2007-2009.</span>