comparison DataTables-1.9.4/media/src/model/model.defaults.columns.js @ 0:ac5f9272033b draft

first upload
author saskia-hiltemann
date Tue, 01 Jul 2014 11:42:23 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:ac5f9272033b
1
2
3 /**
4 * Column options that can be given to DataTables at initialisation time.
5 * @namespace
6 */
7 DataTable.defaults.columns = {
8 /**
9 * Allows a column's sorting to take multiple columns into account when
10 * doing a sort. For example first name / last name columns make sense to
11 * do a multi-column sort over the two columns.
12 * @type array
13 * @default null <i>Takes the value of the column index automatically</i>
14 * @dtopt Columns
15 *
16 * @example
17 * // Using aoColumnDefs
18 * $(document).ready( function() {
19 * $('#example').dataTable( {
20 * "aoColumnDefs": [
21 * { "aDataSort": [ 0, 1 ], "aTargets": [ 0 ] },
22 * { "aDataSort": [ 1, 0 ], "aTargets": [ 1 ] },
23 * { "aDataSort": [ 2, 3, 4 ], "aTargets": [ 2 ] }
24 * ]
25 * } );
26 * } );
27 *
28 * @example
29 * // Using aoColumns
30 * $(document).ready( function() {
31 * $('#example').dataTable( {
32 * "aoColumns": [
33 * { "aDataSort": [ 0, 1 ] },
34 * { "aDataSort": [ 1, 0 ] },
35 * { "aDataSort": [ 2, 3, 4 ] },
36 * null,
37 * null
38 * ]
39 * } );
40 * } );
41 */
42 "aDataSort": null,
43
44
45 /**
46 * You can control the default sorting direction, and even alter the behaviour
47 * of the sort handler (i.e. only allow ascending sorting etc) using this
48 * parameter.
49 * @type array
50 * @default [ 'asc', 'desc' ]
51 * @dtopt Columns
52 *
53 * @example
54 * // Using aoColumnDefs
55 * $(document).ready( function() {
56 * $('#example').dataTable( {
57 * "aoColumnDefs": [
58 * { "asSorting": [ "asc" ], "aTargets": [ 1 ] },
59 * { "asSorting": [ "desc", "asc", "asc" ], "aTargets": [ 2 ] },
60 * { "asSorting": [ "desc" ], "aTargets": [ 3 ] }
61 * ]
62 * } );
63 * } );
64 *
65 * @example
66 * // Using aoColumns
67 * $(document).ready( function() {
68 * $('#example').dataTable( {
69 * "aoColumns": [
70 * null,
71 * { "asSorting": [ "asc" ] },
72 * { "asSorting": [ "desc", "asc", "asc" ] },
73 * { "asSorting": [ "desc" ] },
74 * null
75 * ]
76 * } );
77 * } );
78 */
79 "asSorting": [ 'asc', 'desc' ],
80
81
82 /**
83 * Enable or disable filtering on the data in this column.
84 * @type boolean
85 * @default true
86 * @dtopt Columns
87 *
88 * @example
89 * // Using aoColumnDefs
90 * $(document).ready( function() {
91 * $('#example').dataTable( {
92 * "aoColumnDefs": [
93 * { "bSearchable": false, "aTargets": [ 0 ] }
94 * ] } );
95 * } );
96 *
97 * @example
98 * // Using aoColumns
99 * $(document).ready( function() {
100 * $('#example').dataTable( {
101 * "aoColumns": [
102 * { "bSearchable": false },
103 * null,
104 * null,
105 * null,
106 * null
107 * ] } );
108 * } );
109 */
110 "bSearchable": true,
111
112
113 /**
114 * Enable or disable sorting on this column.
115 * @type boolean
116 * @default true
117 * @dtopt Columns
118 *
119 * @example
120 * // Using aoColumnDefs
121 * $(document).ready( function() {
122 * $('#example').dataTable( {
123 * "aoColumnDefs": [
124 * { "bSortable": false, "aTargets": [ 0 ] }
125 * ] } );
126 * } );
127 *
128 * @example
129 * // Using aoColumns
130 * $(document).ready( function() {
131 * $('#example').dataTable( {
132 * "aoColumns": [
133 * { "bSortable": false },
134 * null,
135 * null,
136 * null,
137 * null
138 * ] } );
139 * } );
140 */
141 "bSortable": true,
142
143
144 /**
145 * <code>Deprecated</code> When using fnRender() for a column, you may wish
146 * to use the original data (before rendering) for sorting and filtering
147 * (the default is to used the rendered data that the user can see). This
148 * may be useful for dates etc.
149 *
150 * Please note that this option has now been deprecated and will be removed
151 * in the next version of DataTables. Please use mRender / mData rather than
152 * fnRender.
153 * @type boolean
154 * @default true
155 * @dtopt Columns
156 * @deprecated
157 */
158 "bUseRendered": true,
159
160
161 /**
162 * Enable or disable the display of this column.
163 * @type boolean
164 * @default true
165 * @dtopt Columns
166 *
167 * @example
168 * // Using aoColumnDefs
169 * $(document).ready( function() {
170 * $('#example').dataTable( {
171 * "aoColumnDefs": [
172 * { "bVisible": false, "aTargets": [ 0 ] }
173 * ] } );
174 * } );
175 *
176 * @example
177 * // Using aoColumns
178 * $(document).ready( function() {
179 * $('#example').dataTable( {
180 * "aoColumns": [
181 * { "bVisible": false },
182 * null,
183 * null,
184 * null,
185 * null
186 * ] } );
187 * } );
188 */
189 "bVisible": true,
190
191
192 /**
193 * Developer definable function that is called whenever a cell is created (Ajax source,
194 * etc) or processed for input (DOM source). This can be used as a compliment to mRender
195 * allowing you to modify the DOM element (add background colour for example) when the
196 * element is available.
197 * @type function
198 * @param {element} nTd The TD node that has been created
199 * @param {*} sData The Data for the cell
200 * @param {array|object} oData The data for the whole row
201 * @param {int} iRow The row index for the aoData data store
202 * @param {int} iCol The column index for aoColumns
203 * @dtopt Columns
204 *
205 * @example
206 * $(document).ready( function() {
207 * $('#example').dataTable( {
208 * "aoColumnDefs": [ {
209 * "aTargets": [3],
210 * "fnCreatedCell": function (nTd, sData, oData, iRow, iCol) {
211 * if ( sData == "1.7" ) {
212 * $(nTd).css('color', 'blue')
213 * }
214 * }
215 * } ]
216 * });
217 * } );
218 */
219 "fnCreatedCell": null,
220
221
222 /**
223 * <code>Deprecated</code> Custom display function that will be called for the
224 * display of each cell in this column.
225 *
226 * Please note that this option has now been deprecated and will be removed
227 * in the next version of DataTables. Please use mRender / mData rather than
228 * fnRender.
229 * @type function
230 * @param {object} o Object with the following parameters:
231 * @param {int} o.iDataRow The row in aoData
232 * @param {int} o.iDataColumn The column in question
233 * @param {array} o.aData The data for the row in question
234 * @param {object} o.oSettings The settings object for this DataTables instance
235 * @param {object} o.mDataProp The data property used for this column
236 * @param {*} val The current cell value
237 * @returns {string} The string you which to use in the display
238 * @dtopt Columns
239 * @deprecated
240 */
241 "fnRender": null,
242
243
244 /**
245 * The column index (starting from 0!) that you wish a sort to be performed
246 * upon when this column is selected for sorting. This can be used for sorting
247 * on hidden columns for example.
248 * @type int
249 * @default -1 <i>Use automatically calculated column index</i>
250 * @dtopt Columns
251 *
252 * @example
253 * // Using aoColumnDefs
254 * $(document).ready( function() {
255 * $('#example').dataTable( {
256 * "aoColumnDefs": [
257 * { "iDataSort": 1, "aTargets": [ 0 ] }
258 * ]
259 * } );
260 * } );
261 *
262 * @example
263 * // Using aoColumns
264 * $(document).ready( function() {
265 * $('#example').dataTable( {
266 * "aoColumns": [
267 * { "iDataSort": 1 },
268 * null,
269 * null,
270 * null,
271 * null
272 * ]
273 * } );
274 * } );
275 */
276 "iDataSort": -1,
277
278
279 /**
280 * This parameter has been replaced by mData in DataTables to ensure naming
281 * consistency. mDataProp can still be used, as there is backwards compatibility
282 * in DataTables for this option, but it is strongly recommended that you use
283 * mData in preference to mDataProp.
284 * @name DataTable.defaults.columns.mDataProp
285 */
286
287
288 /**
289 * This property can be used to read data from any JSON data source property,
290 * including deeply nested objects / properties. mData can be given in a
291 * number of different ways which effect its behaviour:
292 * <ul>
293 * <li>integer - treated as an array index for the data source. This is the
294 * default that DataTables uses (incrementally increased for each column).</li>
295 * <li>string - read an object property from the data source. Note that you can
296 * use Javascript dotted notation to read deep properties / arrays from the
297 * data source.</li>
298 * <li>null - the sDefaultContent option will be used for the cell (null
299 * by default, so you will need to specify the default content you want -
300 * typically an empty string). This can be useful on generated columns such
301 * as edit / delete action columns.</li>
302 * <li>function - the function given will be executed whenever DataTables
303 * needs to set or get the data for a cell in the column. The function
304 * takes three parameters:
305 * <ul>
306 * <li>{array|object} The data source for the row</li>
307 * <li>{string} The type call data requested - this will be 'set' when
308 * setting data or 'filter', 'display', 'type', 'sort' or undefined when
309 * gathering data. Note that when <i>undefined</i> is given for the type
310 * DataTables expects to get the raw data for the object back</li>
311 * <li>{*} Data to set when the second parameter is 'set'.</li>
312 * </ul>
313 * The return value from the function is not required when 'set' is the type
314 * of call, but otherwise the return is what will be used for the data
315 * requested.</li>
316 * </ul>
317 *
318 * Note that prior to DataTables 1.9.2 mData was called mDataProp. The name change
319 * reflects the flexibility of this property and is consistent with the naming of
320 * mRender. If 'mDataProp' is given, then it will still be used by DataTables, as
321 * it automatically maps the old name to the new if required.
322 * @type string|int|function|null
323 * @default null <i>Use automatically calculated column index</i>
324 * @dtopt Columns
325 *
326 * @example
327 * // Read table data from objects
328 * $(document).ready( function() {
329 * var oTable = $('#example').dataTable( {
330 * "sAjaxSource": "sources/deep.txt",
331 * "aoColumns": [
332 * { "mData": "engine" },
333 * { "mData": "browser" },
334 * { "mData": "platform.inner" },
335 * { "mData": "platform.details.0" },
336 * { "mData": "platform.details.1" }
337 * ]
338 * } );
339 * } );
340 *
341 * @example
342 * // Using mData as a function to provide different information for
343 * // sorting, filtering and display. In this case, currency (price)
344 * $(document).ready( function() {
345 * var oTable = $('#example').dataTable( {
346 * "aoColumnDefs": [ {
347 * "aTargets": [ 0 ],
348 * "mData": function ( source, type, val ) {
349 * if (type === 'set') {
350 * source.price = val;
351 * // Store the computed dislay and filter values for efficiency
352 * source.price_display = val=="" ? "" : "$"+numberFormat(val);
353 * source.price_filter = val=="" ? "" : "$"+numberFormat(val)+" "+val;
354 * return;
355 * }
356 * else if (type === 'display') {
357 * return source.price_display;
358 * }
359 * else if (type === 'filter') {
360 * return source.price_filter;
361 * }
362 * // 'sort', 'type' and undefined all just use the integer
363 * return source.price;
364 * }
365 * } ]
366 * } );
367 * } );
368 */
369 "mData": null,
370
371
372 /**
373 * This property is the rendering partner to mData and it is suggested that
374 * when you want to manipulate data for display (including filtering, sorting etc)
375 * but not altering the underlying data for the table, use this property. mData
376 * can actually do everything this property can and more, but this parameter is
377 * easier to use since there is no 'set' option. Like mData is can be given
378 * in a number of different ways to effect its behaviour, with the addition of
379 * supporting array syntax for easy outputting of arrays (including arrays of
380 * objects):
381 * <ul>
382 * <li>integer - treated as an array index for the data source. This is the
383 * default that DataTables uses (incrementally increased for each column).</li>
384 * <li>string - read an object property from the data source. Note that you can
385 * use Javascript dotted notation to read deep properties / arrays from the
386 * data source and also array brackets to indicate that the data reader should
387 * loop over the data source array. When characters are given between the array
388 * brackets, these characters are used to join the data source array together.
389 * For example: "accounts[, ].name" would result in a comma separated list with
390 * the 'name' value from the 'accounts' array of objects.</li>
391 * <li>function - the function given will be executed whenever DataTables
392 * needs to set or get the data for a cell in the column. The function
393 * takes three parameters:
394 * <ul>
395 * <li>{array|object} The data source for the row (based on mData)</li>
396 * <li>{string} The type call data requested - this will be 'filter', 'display',
397 * 'type' or 'sort'.</li>
398 * <li>{array|object} The full data source for the row (not based on mData)</li>
399 * </ul>
400 * The return value from the function is what will be used for the data
401 * requested.</li>
402 * </ul>
403 * @type string|int|function|null
404 * @default null <i>Use mData</i>
405 * @dtopt Columns
406 *
407 * @example
408 * // Create a comma separated list from an array of objects
409 * $(document).ready( function() {
410 * var oTable = $('#example').dataTable( {
411 * "sAjaxSource": "sources/deep.txt",
412 * "aoColumns": [
413 * { "mData": "engine" },
414 * { "mData": "browser" },
415 * {
416 * "mData": "platform",
417 * "mRender": "[, ].name"
418 * }
419 * ]
420 * } );
421 * } );
422 *
423 * @example
424 * // Use as a function to create a link from the data source
425 * $(document).ready( function() {
426 * var oTable = $('#example').dataTable( {
427 * "aoColumnDefs": [
428 * {
429 * "aTargets": [ 0 ],
430 * "mData": "download_link",
431 * "mRender": function ( data, type, full ) {
432 * return '<a href="'+data+'">Download</a>';
433 * }
434 * ]
435 * } );
436 * } );
437 */
438 "mRender": null,
439
440
441 /**
442 * Change the cell type created for the column - either TD cells or TH cells. This
443 * can be useful as TH cells have semantic meaning in the table body, allowing them
444 * to act as a header for a row (you may wish to add scope='row' to the TH elements).
445 * @type string
446 * @default td
447 * @dtopt Columns
448 *
449 * @example
450 * // Make the first column use TH cells
451 * $(document).ready( function() {
452 * var oTable = $('#example').dataTable( {
453 * "aoColumnDefs": [ {
454 * "aTargets": [ 0 ],
455 * "sCellType": "th"
456 * } ]
457 * } );
458 * } );
459 */
460 "sCellType": "td",
461
462
463 /**
464 * Class to give to each cell in this column.
465 * @type string
466 * @default <i>Empty string</i>
467 * @dtopt Columns
468 *
469 * @example
470 * // Using aoColumnDefs
471 * $(document).ready( function() {
472 * $('#example').dataTable( {
473 * "aoColumnDefs": [
474 * { "sClass": "my_class", "aTargets": [ 0 ] }
475 * ]
476 * } );
477 * } );
478 *
479 * @example
480 * // Using aoColumns
481 * $(document).ready( function() {
482 * $('#example').dataTable( {
483 * "aoColumns": [
484 * { "sClass": "my_class" },
485 * null,
486 * null,
487 * null,
488 * null
489 * ]
490 * } );
491 * } );
492 */
493 "sClass": "",
494
495 /**
496 * When DataTables calculates the column widths to assign to each column,
497 * it finds the longest string in each column and then constructs a
498 * temporary table and reads the widths from that. The problem with this
499 * is that "mmm" is much wider then "iiii", but the latter is a longer
500 * string - thus the calculation can go wrong (doing it properly and putting
501 * it into an DOM object and measuring that is horribly(!) slow). Thus as
502 * a "work around" we provide this option. It will append its value to the
503 * text that is found to be the longest string for the column - i.e. padding.
504 * Generally you shouldn't need this, and it is not documented on the
505 * general DataTables.net documentation
506 * @type string
507 * @default <i>Empty string<i>
508 * @dtopt Columns
509 *
510 * @example
511 * // Using aoColumns
512 * $(document).ready( function() {
513 * $('#example').dataTable( {
514 * "aoColumns": [
515 * null,
516 * null,
517 * null,
518 * {
519 * "sContentPadding": "mmm"
520 * }
521 * ]
522 * } );
523 * } );
524 */
525 "sContentPadding": "",
526
527
528 /**
529 * Allows a default value to be given for a column's data, and will be used
530 * whenever a null data source is encountered (this can be because mData
531 * is set to null, or because the data source itself is null).
532 * @type string
533 * @default null
534 * @dtopt Columns
535 *
536 * @example
537 * // Using aoColumnDefs
538 * $(document).ready( function() {
539 * $('#example').dataTable( {
540 * "aoColumnDefs": [
541 * {
542 * "mData": null,
543 * "sDefaultContent": "Edit",
544 * "aTargets": [ -1 ]
545 * }
546 * ]
547 * } );
548 * } );
549 *
550 * @example
551 * // Using aoColumns
552 * $(document).ready( function() {
553 * $('#example').dataTable( {
554 * "aoColumns": [
555 * null,
556 * null,
557 * null,
558 * {
559 * "mData": null,
560 * "sDefaultContent": "Edit"
561 * }
562 * ]
563 * } );
564 * } );
565 */
566 "sDefaultContent": null,
567
568
569 /**
570 * This parameter is only used in DataTables' server-side processing. It can
571 * be exceptionally useful to know what columns are being displayed on the
572 * client side, and to map these to database fields. When defined, the names
573 * also allow DataTables to reorder information from the server if it comes
574 * back in an unexpected order (i.e. if you switch your columns around on the
575 * client-side, your server-side code does not also need updating).
576 * @type string
577 * @default <i>Empty string</i>
578 * @dtopt Columns
579 *
580 * @example
581 * // Using aoColumnDefs
582 * $(document).ready( function() {
583 * $('#example').dataTable( {
584 * "aoColumnDefs": [
585 * { "sName": "engine", "aTargets": [ 0 ] },
586 * { "sName": "browser", "aTargets": [ 1 ] },
587 * { "sName": "platform", "aTargets": [ 2 ] },
588 * { "sName": "version", "aTargets": [ 3 ] },
589 * { "sName": "grade", "aTargets": [ 4 ] }
590 * ]
591 * } );
592 * } );
593 *
594 * @example
595 * // Using aoColumns
596 * $(document).ready( function() {
597 * $('#example').dataTable( {
598 * "aoColumns": [
599 * { "sName": "engine" },
600 * { "sName": "browser" },
601 * { "sName": "platform" },
602 * { "sName": "version" },
603 * { "sName": "grade" }
604 * ]
605 * } );
606 * } );
607 */
608 "sName": "",
609
610
611 /**
612 * Defines a data source type for the sorting which can be used to read
613 * real-time information from the table (updating the internally cached
614 * version) prior to sorting. This allows sorting to occur on user editable
615 * elements such as form inputs.
616 * @type string
617 * @default std
618 * @dtopt Columns
619 *
620 * @example
621 * // Using aoColumnDefs
622 * $(document).ready( function() {
623 * $('#example').dataTable( {
624 * "aoColumnDefs": [
625 * { "sSortDataType": "dom-text", "aTargets": [ 2, 3 ] },
626 * { "sType": "numeric", "aTargets": [ 3 ] },
627 * { "sSortDataType": "dom-select", "aTargets": [ 4 ] },
628 * { "sSortDataType": "dom-checkbox", "aTargets": [ 5 ] }
629 * ]
630 * } );
631 * } );
632 *
633 * @example
634 * // Using aoColumns
635 * $(document).ready( function() {
636 * $('#example').dataTable( {
637 * "aoColumns": [
638 * null,
639 * null,
640 * { "sSortDataType": "dom-text" },
641 * { "sSortDataType": "dom-text", "sType": "numeric" },
642 * { "sSortDataType": "dom-select" },
643 * { "sSortDataType": "dom-checkbox" }
644 * ]
645 * } );
646 * } );
647 */
648 "sSortDataType": "std",
649
650
651 /**
652 * The title of this column.
653 * @type string
654 * @default null <i>Derived from the 'TH' value for this column in the
655 * original HTML table.</i>
656 * @dtopt Columns
657 *
658 * @example
659 * // Using aoColumnDefs
660 * $(document).ready( function() {
661 * $('#example').dataTable( {
662 * "aoColumnDefs": [
663 * { "sTitle": "My column title", "aTargets": [ 0 ] }
664 * ]
665 * } );
666 * } );
667 *
668 * @example
669 * // Using aoColumns
670 * $(document).ready( function() {
671 * $('#example').dataTable( {
672 * "aoColumns": [
673 * { "sTitle": "My column title" },
674 * null,
675 * null,
676 * null,
677 * null
678 * ]
679 * } );
680 * } );
681 */
682 "sTitle": null,
683
684
685 /**
686 * The type allows you to specify how the data for this column will be sorted.
687 * Four types (string, numeric, date and html (which will strip HTML tags
688 * before sorting)) are currently available. Note that only date formats
689 * understood by Javascript's Date() object will be accepted as type date. For
690 * example: "Mar 26, 2008 5:03 PM". May take the values: 'string', 'numeric',
691 * 'date' or 'html' (by default). Further types can be adding through
692 * plug-ins.
693 * @type string
694 * @default null <i>Auto-detected from raw data</i>
695 * @dtopt Columns
696 *
697 * @example
698 * // Using aoColumnDefs
699 * $(document).ready( function() {
700 * $('#example').dataTable( {
701 * "aoColumnDefs": [
702 * { "sType": "html", "aTargets": [ 0 ] }
703 * ]
704 * } );
705 * } );
706 *
707 * @example
708 * // Using aoColumns
709 * $(document).ready( function() {
710 * $('#example').dataTable( {
711 * "aoColumns": [
712 * { "sType": "html" },
713 * null,
714 * null,
715 * null,
716 * null
717 * ]
718 * } );
719 * } );
720 */
721 "sType": null,
722
723
724 /**
725 * Defining the width of the column, this parameter may take any CSS value
726 * (3em, 20px etc). DataTables apples 'smart' widths to columns which have not
727 * been given a specific width through this interface ensuring that the table
728 * remains readable.
729 * @type string
730 * @default null <i>Automatic</i>
731 * @dtopt Columns
732 *
733 * @example
734 * // Using aoColumnDefs
735 * $(document).ready( function() {
736 * $('#example').dataTable( {
737 * "aoColumnDefs": [
738 * { "sWidth": "20%", "aTargets": [ 0 ] }
739 * ]
740 * } );
741 * } );
742 *
743 * @example
744 * // Using aoColumns
745 * $(document).ready( function() {
746 * $('#example').dataTable( {
747 * "aoColumns": [
748 * { "sWidth": "20%" },
749 * null,
750 * null,
751 * null,
752 * null
753 * ]
754 * } );
755 * } );
756 */
757 "sWidth": null
758 };
759