Subversion-Projekte lars-tiefland.cienc

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
9 lars 1
<!DOCTYPE html>
2
<html>
3
<head>
4
	<meta charset="utf-8">
5
	<link rel="shortcut icon" type="image/ico" href="http://www.datatables.net/favicon.ico">
6
	<meta name="viewport" content="initial-scale=1.0, maximum-scale=2.0">
7
 
8
	<title>AutoFill example - Fill plug-ins</title>
9
	<link rel="stylesheet" type="text/css" href="../../../../media/css/jquery.dataTables.css">
10
	<link rel="stylesheet" type="text/css" href="../../css/autoFill.datatables.css">
11
	<link rel="stylesheet" type="text/css" href="../../../../examples/resources/syntax/shCore.css">
12
	<link rel="stylesheet" type="text/css" href="../../../../examples/resources/demo.css">
13
	<style type="text/css" class="init">
14
 
15
	</style>
16
	<script type="text/javascript" language="javascript" src="//code.jquery.com/jquery-1.11.3.min.js"></script>
17
	<script type="text/javascript" language="javascript" src="../../../../media/js/jquery.dataTables.js"></script>
18
	<script type="text/javascript" language="javascript" src="../../js/dataTables.autoFill.js"></script>
19
	<script type="text/javascript" language="javascript" src="../../../../examples/resources/syntax/shCore.js"></script>
20
	<script type="text/javascript" language="javascript" src="../../../../examples/resources/demo.js"></script>
21
	<script type="text/javascript" language="javascript" class="init">
22
 
23
 
24
 
25
$.fn.dataTable.AutoFill.actions.names = {
26
	available: function ( dt, cells ) {
27
		// Only available if a single column is being
28
		// filled and it is the first column
29
		return cells[0].length === 1 && cells[0][0].index.column === 0;
30
	},
31
 
32
	option: function ( dt, cells ) {
33
		// Ask the user if they want to change the surname only
34
		return 'Fill only surname - retain first name';
35
	},
36
 
37
	execute: function ( dt, cells, node ) {
38
		// Modify the name and set the new values
39
		var surname = cells[0][0].data.split(' ')[1];
40
 
41
		for ( var i=0, ien=cells.length ; i<ien ; i++ ) {
42
			var name = cells[i][0].data.split(' ');
43
 
44
			cells[i][0].set = name[0]+' '+surname;
45
		}
46
	}
47
}
48
 
49
$(document).ready(function() {
50
	$('#example').DataTable( {
51
		autoFill: true
52
	} );
53
} );
54
 
55
 
56
	</script>
57
</head>
58
 
59
<body class="dt-example">
60
	<div class="container">
61
		<section>
62
			<h1>AutoFill example <span>Fill plug-ins</span></h1>
63
 
64
			<div class="info">
65
				<p>AutoFill provides a <a href="fills.html">number of built in fill types</a>, but these built in options can be augmented with additional options using
66
				plug-ins.</p>
67
 
68
				<p>The fill options are provided by plug-ins which are attached to the <code>$.fn.dataTable.AutoFill.actions</code> object. Each property in this object must be an
69
				object that provides three functions:</p>
70
 
71
				<ul class="markdown">
72
					<li><code>available</code> - Determine if the data that the user dragged the fill over is suitable for this fill type</li>
73
					<li><code>option</code> - Returns a question the user will be asked for if they want to use this fill type</li>
74
					<li><code>execute</code> - Modifies the data if this fill type is selected</li>
75
				</ul>
76
 
77
				<p>The example shows a plug-in that will operate only on the first column in the table and will change only the surname - retaining the forename from the original
78
				cell. While slightly contrived as an example, it demonstrates how plug-ins can perform potentially complex operations.</p>
79
 
80
				<p>For full details about creating fill plug-ins for AutoFill, please refer to the <a href="https://datatables.net/extensions/autofill">online
81
				documentation</a>.</p>
82
			</div>
83
 
84
			<table id="example" class="display nowrap" cellspacing="0" width="100%">
85
				<thead>
86
					<tr>
87
						<th>Name</th>
88
						<th>Position</th>
89
						<th>Office</th>
90
						<th>Age</th>
91
						<th>Start date</th>
92
						<th>Salary</th>
93
					</tr>
94
				</thead>
95
 
96
				<tfoot>
97
					<tr>
98
						<th>Name</th>
99
						<th>Position</th>
100
						<th>Office</th>
101
						<th>Age</th>
102
						<th>Start date</th>
103
						<th>Salary</th>
104
					</tr>
105
				</tfoot>
106
 
107
				<tbody>
108
					<tr>
109
						<td>Tiger Nixon</td>
110
						<td>System Architect</td>
111
						<td>Edinburgh</td>
112
						<td>61</td>
113
						<td>2011/04/25</td>
114
						<td>$320,800</td>
115
					</tr>
116
					<tr>
117
						<td>Garrett Winters</td>
118
						<td>Accountant</td>
119
						<td>Tokyo</td>
120
						<td>63</td>
121
						<td>2011/07/25</td>
122
						<td>$170,750</td>
123
					</tr>
124
					<tr>
125
						<td>Ashton Cox</td>
126
						<td>Junior Technical Author</td>
127
						<td>San Francisco</td>
128
						<td>66</td>
129
						<td>2009/01/12</td>
130
						<td>$86,000</td>
131
					</tr>
132
					<tr>
133
						<td>Cedric Kelly</td>
134
						<td>Senior Javascript Developer</td>
135
						<td>Edinburgh</td>
136
						<td>22</td>
137
						<td>2012/03/29</td>
138
						<td>$433,060</td>
139
					</tr>
140
					<tr>
141
						<td>Airi Satou</td>
142
						<td>Accountant</td>
143
						<td>Tokyo</td>
144
						<td>33</td>
145
						<td>2008/11/28</td>
146
						<td>$162,700</td>
147
					</tr>
148
					<tr>
149
						<td>Brielle Williamson</td>
150
						<td>Integration Specialist</td>
151
						<td>New York</td>
152
						<td>61</td>
153
						<td>2012/12/02</td>
154
						<td>$372,000</td>
155
					</tr>
156
					<tr>
157
						<td>Herrod Chandler</td>
158
						<td>Sales Assistant</td>
159
						<td>San Francisco</td>
160
						<td>59</td>
161
						<td>2012/08/06</td>
162
						<td>$137,500</td>
163
					</tr>
164
					<tr>
165
						<td>Rhona Davidson</td>
166
						<td>Integration Specialist</td>
167
						<td>Tokyo</td>
168
						<td>55</td>
169
						<td>2010/10/14</td>
170
						<td>$327,900</td>
171
					</tr>
172
					<tr>
173
						<td>Colleen Hurst</td>
174
						<td>Javascript Developer</td>
175
						<td>San Francisco</td>
176
						<td>39</td>
177
						<td>2009/09/15</td>
178
						<td>$205,500</td>
179
					</tr>
180
					<tr>
181
						<td>Sonya Frost</td>
182
						<td>Software Engineer</td>
183
						<td>Edinburgh</td>
184
						<td>23</td>
185
						<td>2008/12/13</td>
186
						<td>$103,600</td>
187
					</tr>
188
					<tr>
189
						<td>Jena Gaines</td>
190
						<td>Office Manager</td>
191
						<td>London</td>
192
						<td>30</td>
193
						<td>2008/12/19</td>
194
						<td>$90,560</td>
195
					</tr>
196
					<tr>
197
						<td>Quinn Flynn</td>
198
						<td>Support Lead</td>
199
						<td>Edinburgh</td>
200
						<td>22</td>
201
						<td>2013/03/03</td>
202
						<td>$342,000</td>
203
					</tr>
204
					<tr>
205
						<td>Charde Marshall</td>
206
						<td>Regional Director</td>
207
						<td>San Francisco</td>
208
						<td>36</td>
209
						<td>2008/10/16</td>
210
						<td>$470,600</td>
211
					</tr>
212
					<tr>
213
						<td>Haley Kennedy</td>
214
						<td>Senior Marketing Designer</td>
215
						<td>London</td>
216
						<td>43</td>
217
						<td>2012/12/18</td>
218
						<td>$313,500</td>
219
					</tr>
220
					<tr>
221
						<td>Tatyana Fitzpatrick</td>
222
						<td>Regional Director</td>
223
						<td>London</td>
224
						<td>19</td>
225
						<td>2010/03/17</td>
226
						<td>$385,750</td>
227
					</tr>
228
					<tr>
229
						<td>Michael Silva</td>
230
						<td>Marketing Designer</td>
231
						<td>London</td>
232
						<td>66</td>
233
						<td>2012/11/27</td>
234
						<td>$198,500</td>
235
					</tr>
236
					<tr>
237
						<td>Paul Byrd</td>
238
						<td>Chief Financial Officer (CFO)</td>
239
						<td>New York</td>
240
						<td>64</td>
241
						<td>2010/06/09</td>
242
						<td>$725,000</td>
243
					</tr>
244
					<tr>
245
						<td>Gloria Little</td>
246
						<td>Systems Administrator</td>
247
						<td>New York</td>
248
						<td>59</td>
249
						<td>2009/04/10</td>
250
						<td>$237,500</td>
251
					</tr>
252
					<tr>
253
						<td>Bradley Greer</td>
254
						<td>Software Engineer</td>
255
						<td>London</td>
256
						<td>41</td>
257
						<td>2012/10/13</td>
258
						<td>$132,000</td>
259
					</tr>
260
					<tr>
261
						<td>Dai Rios</td>
262
						<td>Personnel Lead</td>
263
						<td>Edinburgh</td>
264
						<td>35</td>
265
						<td>2012/09/26</td>
266
						<td>$217,500</td>
267
					</tr>
268
					<tr>
269
						<td>Jenette Caldwell</td>
270
						<td>Development Lead</td>
271
						<td>New York</td>
272
						<td>30</td>
273
						<td>2011/09/03</td>
274
						<td>$345,000</td>
275
					</tr>
276
					<tr>
277
						<td>Yuri Berry</td>
278
						<td>Chief Marketing Officer (CMO)</td>
279
						<td>New York</td>
280
						<td>40</td>
281
						<td>2009/06/25</td>
282
						<td>$675,000</td>
283
					</tr>
284
					<tr>
285
						<td>Caesar Vance</td>
286
						<td>Pre-Sales Support</td>
287
						<td>New York</td>
288
						<td>21</td>
289
						<td>2011/12/12</td>
290
						<td>$106,450</td>
291
					</tr>
292
					<tr>
293
						<td>Doris Wilder</td>
294
						<td>Sales Assistant</td>
295
						<td>Sidney</td>
296
						<td>23</td>
297
						<td>2010/09/20</td>
298
						<td>$85,600</td>
299
					</tr>
300
					<tr>
301
						<td>Angelica Ramos</td>
302
						<td>Chief Executive Officer (CEO)</td>
303
						<td>London</td>
304
						<td>47</td>
305
						<td>2009/10/09</td>
306
						<td>$1,200,000</td>
307
					</tr>
308
					<tr>
309
						<td>Gavin Joyce</td>
310
						<td>Developer</td>
311
						<td>Edinburgh</td>
312
						<td>42</td>
313
						<td>2010/12/22</td>
314
						<td>$92,575</td>
315
					</tr>
316
					<tr>
317
						<td>Jennifer Chang</td>
318
						<td>Regional Director</td>
319
						<td>Singapore</td>
320
						<td>28</td>
321
						<td>2010/11/14</td>
322
						<td>$357,650</td>
323
					</tr>
324
					<tr>
325
						<td>Brenden Wagner</td>
326
						<td>Software Engineer</td>
327
						<td>San Francisco</td>
328
						<td>28</td>
329
						<td>2011/06/07</td>
330
						<td>$206,850</td>
331
					</tr>
332
					<tr>
333
						<td>Fiona Green</td>
334
						<td>Chief Operating Officer (COO)</td>
335
						<td>San Francisco</td>
336
						<td>48</td>
337
						<td>2010/03/11</td>
338
						<td>$850,000</td>
339
					</tr>
340
					<tr>
341
						<td>Shou Itou</td>
342
						<td>Regional Marketing</td>
343
						<td>Tokyo</td>
344
						<td>20</td>
345
						<td>2011/08/14</td>
346
						<td>$163,000</td>
347
					</tr>
348
					<tr>
349
						<td>Michelle House</td>
350
						<td>Integration Specialist</td>
351
						<td>Sidney</td>
352
						<td>37</td>
353
						<td>2011/06/02</td>
354
						<td>$95,400</td>
355
					</tr>
356
					<tr>
357
						<td>Suki Burks</td>
358
						<td>Developer</td>
359
						<td>London</td>
360
						<td>53</td>
361
						<td>2009/10/22</td>
362
						<td>$114,500</td>
363
					</tr>
364
					<tr>
365
						<td>Prescott Bartlett</td>
366
						<td>Technical Author</td>
367
						<td>London</td>
368
						<td>27</td>
369
						<td>2011/05/07</td>
370
						<td>$145,000</td>
371
					</tr>
372
					<tr>
373
						<td>Gavin Cortez</td>
374
						<td>Team Leader</td>
375
						<td>San Francisco</td>
376
						<td>22</td>
377
						<td>2008/10/26</td>
378
						<td>$235,500</td>
379
					</tr>
380
					<tr>
381
						<td>Martena Mccray</td>
382
						<td>Post-Sales support</td>
383
						<td>Edinburgh</td>
384
						<td>46</td>
385
						<td>2011/03/09</td>
386
						<td>$324,050</td>
387
					</tr>
388
					<tr>
389
						<td>Unity Butler</td>
390
						<td>Marketing Designer</td>
391
						<td>San Francisco</td>
392
						<td>47</td>
393
						<td>2009/12/09</td>
394
						<td>$85,675</td>
395
					</tr>
396
					<tr>
397
						<td>Howard Hatfield</td>
398
						<td>Office Manager</td>
399
						<td>San Francisco</td>
400
						<td>51</td>
401
						<td>2008/12/16</td>
402
						<td>$164,500</td>
403
					</tr>
404
					<tr>
405
						<td>Hope Fuentes</td>
406
						<td>Secretary</td>
407
						<td>San Francisco</td>
408
						<td>41</td>
409
						<td>2010/02/12</td>
410
						<td>$109,850</td>
411
					</tr>
412
					<tr>
413
						<td>Vivian Harrell</td>
414
						<td>Financial Controller</td>
415
						<td>San Francisco</td>
416
						<td>62</td>
417
						<td>2009/02/14</td>
418
						<td>$452,500</td>
419
					</tr>
420
					<tr>
421
						<td>Timothy Mooney</td>
422
						<td>Office Manager</td>
423
						<td>London</td>
424
						<td>37</td>
425
						<td>2008/12/11</td>
426
						<td>$136,200</td>
427
					</tr>
428
					<tr>
429
						<td>Jackson Bradshaw</td>
430
						<td>Director</td>
431
						<td>New York</td>
432
						<td>65</td>
433
						<td>2008/09/26</td>
434
						<td>$645,750</td>
435
					</tr>
436
					<tr>
437
						<td>Olivia Liang</td>
438
						<td>Support Engineer</td>
439
						<td>Singapore</td>
440
						<td>64</td>
441
						<td>2011/02/03</td>
442
						<td>$234,500</td>
443
					</tr>
444
					<tr>
445
						<td>Bruno Nash</td>
446
						<td>Software Engineer</td>
447
						<td>London</td>
448
						<td>38</td>
449
						<td>2011/05/03</td>
450
						<td>$163,500</td>
451
					</tr>
452
					<tr>
453
						<td>Sakura Yamamoto</td>
454
						<td>Support Engineer</td>
455
						<td>Tokyo</td>
456
						<td>37</td>
457
						<td>2009/08/19</td>
458
						<td>$139,575</td>
459
					</tr>
460
					<tr>
461
						<td>Thor Walton</td>
462
						<td>Developer</td>
463
						<td>New York</td>
464
						<td>61</td>
465
						<td>2013/08/11</td>
466
						<td>$98,540</td>
467
					</tr>
468
					<tr>
469
						<td>Finn Camacho</td>
470
						<td>Support Engineer</td>
471
						<td>San Francisco</td>
472
						<td>47</td>
473
						<td>2009/07/07</td>
474
						<td>$87,500</td>
475
					</tr>
476
					<tr>
477
						<td>Serge Baldwin</td>
478
						<td>Data Coordinator</td>
479
						<td>Singapore</td>
480
						<td>64</td>
481
						<td>2012/04/09</td>
482
						<td>$138,575</td>
483
					</tr>
484
					<tr>
485
						<td>Zenaida Frank</td>
486
						<td>Software Engineer</td>
487
						<td>New York</td>
488
						<td>63</td>
489
						<td>2010/01/04</td>
490
						<td>$125,250</td>
491
					</tr>
492
					<tr>
493
						<td>Zorita Serrano</td>
494
						<td>Software Engineer</td>
495
						<td>San Francisco</td>
496
						<td>56</td>
497
						<td>2012/06/01</td>
498
						<td>$115,000</td>
499
					</tr>
500
					<tr>
501
						<td>Jennifer Acosta</td>
502
						<td>Junior Javascript Developer</td>
503
						<td>Edinburgh</td>
504
						<td>43</td>
505
						<td>2013/02/01</td>
506
						<td>$75,650</td>
507
					</tr>
508
					<tr>
509
						<td>Cara Stevens</td>
510
						<td>Sales Assistant</td>
511
						<td>New York</td>
512
						<td>46</td>
513
						<td>2011/12/06</td>
514
						<td>$145,600</td>
515
					</tr>
516
					<tr>
517
						<td>Hermione Butler</td>
518
						<td>Regional Director</td>
519
						<td>London</td>
520
						<td>47</td>
521
						<td>2011/03/21</td>
522
						<td>$356,250</td>
523
					</tr>
524
					<tr>
525
						<td>Lael Greer</td>
526
						<td>Systems Administrator</td>
527
						<td>London</td>
528
						<td>21</td>
529
						<td>2009/02/27</td>
530
						<td>$103,500</td>
531
					</tr>
532
					<tr>
533
						<td>Jonas Alexander</td>
534
						<td>Developer</td>
535
						<td>San Francisco</td>
536
						<td>30</td>
537
						<td>2010/07/14</td>
538
						<td>$86,500</td>
539
					</tr>
540
					<tr>
541
						<td>Shad Decker</td>
542
						<td>Regional Director</td>
543
						<td>Edinburgh</td>
544
						<td>51</td>
545
						<td>2008/11/13</td>
546
						<td>$183,000</td>
547
					</tr>
548
					<tr>
549
						<td>Michael Bruce</td>
550
						<td>Javascript Developer</td>
551
						<td>Singapore</td>
552
						<td>29</td>
553
						<td>2011/06/27</td>
554
						<td>$183,000</td>
555
					</tr>
556
					<tr>
557
						<td>Donna Snider</td>
558
						<td>Customer Support</td>
559
						<td>New York</td>
560
						<td>27</td>
561
						<td>2011/01/25</td>
562
						<td>$112,000</td>
563
					</tr>
564
				</tbody>
565
			</table>
566
 
567
			<ul class="tabs">
568
				<li class="active">Javascript</li>
569
				<li>HTML</li>
570
				<li>CSS</li>
571
				<li>Ajax</li>
572
				<li>Server-side script</li>
573
			</ul>
574
 
575
			<div class="tabs">
576
				<div class="js">
577
					<p>The Javascript shown below is used to initialise the table shown in this example:</p><code class="multiline language-js">$.fn.dataTable.AutoFill.actions.names = {
578
	available: function ( dt, cells ) {
579
		// Only available if a single column is being
580
		// filled and it is the first column
581
		return cells[0].length === 1 &amp;&amp; cells[0][0].index.column === 0;
582
	},
583
 
584
	option: function ( dt, cells ) {
585
		// Ask the user if they want to change the surname only
586
		return 'Fill only surname - retain first name';
587
	},
588
 
589
	execute: function ( dt, cells, node ) {
590
		// Modify the name and set the new values
591
		var surname = cells[0][0].data.split(' ')[1];
592
 
593
		for ( var i=0, ien=cells.length ; i&lt;ien ; i++ ) {
594
			var name = cells[i][0].data.split(' ');
595
 
596
			cells[i][0].set = name[0]+' '+surname;
597
		}
598
	}
599
}
600
 
601
$(document).ready(function() {
602
	$('#example').DataTable( {
603
		autoFill: true
604
	} );
605
} );</code>
606
 
607
					<p>In addition to the above code, the following Javascript library files are loaded for use in this example:</p>
608
 
609
					<ul>
610
						<li><a href="//code.jquery.com/jquery-1.11.3.min.js">//code.jquery.com/jquery-1.11.3.min.js</a></li>
611
						<li><a href="../../../../media/js/jquery.dataTables.js">../../../../media/js/jquery.dataTables.js</a></li>
612
						<li><a href="../../js/dataTables.autoFill.js">../../js/dataTables.autoFill.js</a></li>
613
					</ul>
614
				</div>
615
 
616
				<div class="table">
617
					<p>The HTML shown below is the raw HTML table element, before it has been enhanced by DataTables:</p>
618
				</div>
619
 
620
				<div class="css">
621
					<div>
622
						<p>This example uses a little bit of additional CSS beyond what is loaded from the library files (below), in order to correctly display the table. The
623
						additional CSS used is shown below:</p><code class="multiline language-css"></code>
624
					</div>
625
 
626
					<p>The following CSS library files are loaded for use in this example to provide the styling of the table:</p>
627
 
628
					<ul>
629
						<li><a href="../../../../media/css/jquery.dataTables.css">../../../../media/css/jquery.dataTables.css</a></li>
630
						<li><a href="../../css/autoFill.datatables.css">../../css/autoFill.datatables.css</a></li>
631
					</ul>
632
				</div>
633
 
634
				<div class="ajax">
635
					<p>This table loads data by Ajax. The latest data that has been loaded is shown below. This data will update automatically as any additional data is
636
					loaded.</p>
637
				</div>
638
 
639
				<div class="php">
640
					<p>The script used to perform the server-side processing for this table is shown below. Please note that this is just an example script using PHP. Server-side
641
					processing scripts can be written in any language, using <a href="//datatables.net/manual/server-side">the protocol described in the DataTables
642
					documentation</a>.</p>
643
				</div>
644
			</div>
645
		</section>
646
	</div>
647
 
648
	<section>
649
		<div class="footer">
650
			<div class="gradient"></div>
651
 
652
			<div class="liner">
653
				<h2>Other examples</h2>
654
 
655
				<div class="toc">
656
					<div class="toc-group">
657
						<h3><a href="./index.html">Initialisation</a></h3>
658
						<ul class="toc active">
659
							<li><a href="./simple.html">Basic initialisation</a></li>
660
							<li><a href="./fills.html">Fill types</a></li>
661
							<li><a href="./keyTable.html">KeyTable integration</a></li>
662
							<li><a href="./events.html">Events</a></li>
663
							<li><a href="./alwaysAsk.html">Always confirm action</a></li>
664
							<li><a href="./columns.html">Column selector</a></li>
665
							<li><a href="./focus.html">Click focus</a></li>
666
							<li><a href="./scrolling.html">Scrolling DataTable</a></li>
667
							<li class="active"><a href="./plugins.html">Fill plug-ins</a></li>
668
						</ul>
669
					</div>
670
 
671
					<div class="toc-group">
672
						<h3><a href="../styling/index.html">Styling</a></h3>
673
						<ul class="toc">
674
							<li><a href="../styling/bootstrap.html">Bootstrap styling</a></li>
675
							<li><a href="../styling/foundation.html">Foundation styling</a></li>
676
							<li><a href="../styling/jqueryui.html">jQuery UI styling</a></li>
677
						</ul>
678
					</div>
679
				</div>
680
 
681
				<div class="epilogue">
682
					<p>Please refer to the <a href="http://www.datatables.net">DataTables documentation</a> for full information about its API properties and methods.<br>
683
					Additionally, there are a wide range of <a href="http://www.datatables.net/extensions">extensions</a> and <a href=
684
					"http://www.datatables.net/plug-ins">plug-ins</a> which extend the capabilities of DataTables.</p>
685
 
686
					<p class="copyright">DataTables designed and created by <a href="http://www.sprymedia.co.uk">SpryMedia Ltd</a> &#169; 2007-2015<br>
687
					DataTables is licensed under the <a href="http://www.datatables.net/mit">MIT license</a>.</p>
688
				</div>
689
			</div>
690
		</div>
691
	</section>
692
</body>
693
</html>