annotate jquery.dataTables.js @ 9:7300ed4c1481 draft default tip

Uploaded
author saskia-hiltemann
date Mon, 04 Sep 2017 10:49:00 -0400
parents 42076db43d42
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2 * @summary DataTables
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3 * @description Paginate, search and sort HTML tables
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4 * @version 1.9.4
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5 * @file jquery.dataTables.js
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6 * @author Allan Jardine (www.sprymedia.co.uk)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7 * @contact www.sprymedia.co.uk/contact
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9 * @copyright Copyright 2008-2012 Allan Jardine, all rights reserved.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11 * This source file is free software, under either the GPL v2 license or a
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12 * BSD style license, available at:
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
13 * http://datatables.net/license_gpl2
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
14 * http://datatables.net/license_bsd
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
15 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
16 * This source file is distributed in the hope that it will be useful, but
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
17 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
18 * or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
19 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
20 * For details please refer to: http://www.datatables.net
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
21 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
22
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
23 /*jslint evil: true, undef: true, browser: true */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
24 /*globals $, jQuery,define,_fnExternApiFunc,_fnInitialise,_fnInitComplete,_fnLanguageCompat,_fnAddColumn,_fnColumnOptions,_fnAddData,_fnCreateTr,_fnGatherData,_fnBuildHead,_fnDrawHead,_fnDraw,_fnReDraw,_fnAjaxUpdate,_fnAjaxParameters,_fnAjaxUpdateDraw,_fnServerParams,_fnAddOptionsHtml,_fnFeatureHtmlTable,_fnScrollDraw,_fnAdjustColumnSizing,_fnFeatureHtmlFilter,_fnFilterComplete,_fnFilterCustom,_fnFilterColumn,_fnFilter,_fnBuildSearchArray,_fnBuildSearchRow,_fnFilterCreateSearch,_fnDataToSearch,_fnSort,_fnSortAttachListener,_fnSortingClasses,_fnFeatureHtmlPaginate,_fnPageChange,_fnFeatureHtmlInfo,_fnUpdateInfo,_fnFeatureHtmlLength,_fnFeatureHtmlProcessing,_fnProcessingDisplay,_fnVisibleToColumnIndex,_fnColumnIndexToVisible,_fnNodeToDataIndex,_fnVisbleColumns,_fnCalculateEnd,_fnConvertToWidth,_fnCalculateColumnWidths,_fnScrollingWidthAdjust,_fnGetWidestNode,_fnGetMaxLenString,_fnStringToCss,_fnDetectType,_fnSettingsFromNode,_fnGetDataMaster,_fnGetTrNodes,_fnGetTdNodes,_fnEscapeRegex,_fnDeleteIndex,_fnReOrderIndex,_fnColumnOrdering,_fnLog,_fnClearTable,_fnSaveState,_fnLoadState,_fnCreateCookie,_fnReadCookie,_fnDetectHeader,_fnGetUniqueThs,_fnScrollBarWidth,_fnApplyToChildren,_fnMap,_fnGetRowData,_fnGetCellData,_fnSetCellData,_fnGetObjectDataFn,_fnSetObjectDataFn,_fnApplyColumnDefs,_fnBindAction,_fnCallbackReg,_fnCallbackFire,_fnJsonString,_fnRender,_fnNodeToColumnIndex,_fnInfoMacros,_fnBrowserDetect,_fnGetColumns*/
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
25
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
26 (/** @lends <global> */function( window, document, undefined ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
27
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
28 (function( factory ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
29 "use strict";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
30
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
31 // Define as an AMD module if possible
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
32 if ( typeof define === 'function' && define.amd )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
33 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
34 define( ['jquery'], factory );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
35 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
36 /* Define using browser globals otherwise
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
37 * Prevent multiple instantiations if the script is loaded twice
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
38 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
39 else if ( jQuery && !jQuery.fn.dataTable )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
40 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
41 factory( jQuery );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
42 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
43 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
44 (/** @lends <global> */function( $ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
45 "use strict";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
46 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
47 * DataTables is a plug-in for the jQuery Javascript library. It is a
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
48 * highly flexible tool, based upon the foundations of progressive
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
49 * enhancement, which will add advanced interaction controls to any
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
50 * HTML table. For a full list of features please refer to
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
51 * <a href="http://datatables.net">DataTables.net</a>.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
52 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
53 * Note that the <i>DataTable</i> object is not a global variable but is
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
54 * aliased to <i>jQuery.fn.DataTable</i> and <i>jQuery.fn.dataTable</i> through which
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
55 * it may be accessed.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
56 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
57 * @class
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
58 * @param {object} [oInit={}] Configuration object for DataTables. Options
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
59 * are defined by {@link DataTable.defaults}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
60 * @requires jQuery 1.3+
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
61 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
62 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
63 * // Basic initialisation
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
64 * $(document).ready( function {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
65 * $('#example').dataTable();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
66 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
67 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
68 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
69 * // Initialisation with configuration options - in this case, disable
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
70 * // pagination and sorting.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
71 * $(document).ready( function {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
72 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
73 * "bPaginate": false,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
74 * "bSort": false
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
75 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
76 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
77 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
78 var DataTable = function( oInit )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
79 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
80
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
81
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
82 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
83 * Add a column to the list used for the table with default values
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
84 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
85 * @param {node} nTh The th element for this column
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
86 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
87 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
88 function _fnAddColumn( oSettings, nTh )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
89 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
90 var oDefaults = DataTable.defaults.columns;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
91 var iCol = oSettings.aoColumns.length;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
92 var oCol = $.extend( {}, DataTable.models.oColumn, oDefaults, {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
93 "sSortingClass": oSettings.oClasses.sSortable,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
94 "sSortingClassJUI": oSettings.oClasses.sSortJUI,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
95 "nTh": nTh ? nTh : document.createElement('th'),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
96 "sTitle": oDefaults.sTitle ? oDefaults.sTitle : nTh ? nTh.innerHTML : '',
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
97 "aDataSort": oDefaults.aDataSort ? oDefaults.aDataSort : [iCol],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
98 "mData": oDefaults.mData ? oDefaults.oDefaults : iCol
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
99 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
100 oSettings.aoColumns.push( oCol );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
101
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
102 /* Add a column specific filter */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
103 if ( oSettings.aoPreSearchCols[ iCol ] === undefined || oSettings.aoPreSearchCols[ iCol ] === null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
104 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
105 oSettings.aoPreSearchCols[ iCol ] = $.extend( {}, DataTable.models.oSearch );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
106 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
107 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
108 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
109 var oPre = oSettings.aoPreSearchCols[ iCol ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
110
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
111 /* Don't require that the user must specify bRegex, bSmart or bCaseInsensitive */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
112 if ( oPre.bRegex === undefined )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
113 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
114 oPre.bRegex = true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
115 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
116
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
117 if ( oPre.bSmart === undefined )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
118 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
119 oPre.bSmart = true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
120 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
121
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
122 if ( oPre.bCaseInsensitive === undefined )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
123 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
124 oPre.bCaseInsensitive = true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
125 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
126 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
127
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
128 /* Use the column options function to initialise classes etc */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
129 _fnColumnOptions( oSettings, iCol, null );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
130 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
131
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
132
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
133 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
134 * Apply options for a column
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
135 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
136 * @param {int} iCol column index to consider
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
137 * @param {object} oOptions object with sType, bVisible and bSearchable etc
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
138 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
139 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
140 function _fnColumnOptions( oSettings, iCol, oOptions )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
141 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
142 var oCol = oSettings.aoColumns[ iCol ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
143
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
144 /* User specified column options */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
145 if ( oOptions !== undefined && oOptions !== null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
146 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
147 /* Backwards compatibility for mDataProp */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
148 if ( oOptions.mDataProp && !oOptions.mData )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
149 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
150 oOptions.mData = oOptions.mDataProp;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
151 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
152
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
153 if ( oOptions.sType !== undefined )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
154 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
155 oCol.sType = oOptions.sType;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
156 oCol._bAutoType = false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
157 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
158
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
159 $.extend( oCol, oOptions );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
160 _fnMap( oCol, oOptions, "sWidth", "sWidthOrig" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
161
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
162 /* iDataSort to be applied (backwards compatibility), but aDataSort will take
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
163 * priority if defined
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
164 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
165 if ( oOptions.iDataSort !== undefined )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
166 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
167 oCol.aDataSort = [ oOptions.iDataSort ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
168 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
169 _fnMap( oCol, oOptions, "aDataSort" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
170 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
171
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
172 /* Cache the data get and set functions for speed */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
173 var mRender = oCol.mRender ? _fnGetObjectDataFn( oCol.mRender ) : null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
174 var mData = _fnGetObjectDataFn( oCol.mData );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
175
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
176 oCol.fnGetData = function (oData, sSpecific) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
177 var innerData = mData( oData, sSpecific );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
178
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
179 if ( oCol.mRender && (sSpecific && sSpecific !== '') )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
180 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
181 return mRender( innerData, sSpecific, oData );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
182 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
183 return innerData;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
184 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
185 oCol.fnSetData = _fnSetObjectDataFn( oCol.mData );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
186
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
187 /* Feature sorting overrides column specific when off */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
188 if ( !oSettings.oFeatures.bSort )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
189 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
190 oCol.bSortable = false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
191 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
192
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
193 /* Check that the class assignment is correct for sorting */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
194 if ( !oCol.bSortable ||
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
195 ($.inArray('asc', oCol.asSorting) == -1 && $.inArray('desc', oCol.asSorting) == -1) )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
196 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
197 oCol.sSortingClass = oSettings.oClasses.sSortableNone;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
198 oCol.sSortingClassJUI = "";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
199 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
200 else if ( $.inArray('asc', oCol.asSorting) == -1 && $.inArray('desc', oCol.asSorting) == -1 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
201 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
202 oCol.sSortingClass = oSettings.oClasses.sSortable;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
203 oCol.sSortingClassJUI = oSettings.oClasses.sSortJUI;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
204 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
205 else if ( $.inArray('asc', oCol.asSorting) != -1 && $.inArray('desc', oCol.asSorting) == -1 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
206 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
207 oCol.sSortingClass = oSettings.oClasses.sSortableAsc;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
208 oCol.sSortingClassJUI = oSettings.oClasses.sSortJUIAscAllowed;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
209 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
210 else if ( $.inArray('asc', oCol.asSorting) == -1 && $.inArray('desc', oCol.asSorting) != -1 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
211 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
212 oCol.sSortingClass = oSettings.oClasses.sSortableDesc;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
213 oCol.sSortingClassJUI = oSettings.oClasses.sSortJUIDescAllowed;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
214 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
215 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
216
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
217
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
218 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
219 * Adjust the table column widths for new data. Note: you would probably want to
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
220 * do a redraw after calling this function!
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
221 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
222 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
223 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
224 function _fnAdjustColumnSizing ( oSettings )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
225 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
226 /* Not interested in doing column width calculation if auto-width is disabled */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
227 if ( oSettings.oFeatures.bAutoWidth === false )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
228 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
229 return false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
230 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
231
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
232 _fnCalculateColumnWidths( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
233 for ( var i=0 , iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
234 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
235 oSettings.aoColumns[i].nTh.style.width = oSettings.aoColumns[i].sWidth;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
236 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
237 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
238
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
239
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
240 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
241 * Covert the index of a visible column to the index in the data array (take account
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
242 * of hidden columns)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
243 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
244 * @param {int} iMatch Visible column index to lookup
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
245 * @returns {int} i the data index
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
246 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
247 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
248 function _fnVisibleToColumnIndex( oSettings, iMatch )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
249 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
250 var aiVis = _fnGetColumns( oSettings, 'bVisible' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
251
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
252 return typeof aiVis[iMatch] === 'number' ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
253 aiVis[iMatch] :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
254 null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
255 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
256
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
257
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
258 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
259 * Covert the index of an index in the data array and convert it to the visible
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
260 * column index (take account of hidden columns)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
261 * @param {int} iMatch Column index to lookup
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
262 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
263 * @returns {int} i the data index
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
264 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
265 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
266 function _fnColumnIndexToVisible( oSettings, iMatch )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
267 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
268 var aiVis = _fnGetColumns( oSettings, 'bVisible' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
269 var iPos = $.inArray( iMatch, aiVis );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
270
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
271 return iPos !== -1 ? iPos : null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
272 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
273
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
274
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
275 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
276 * Get the number of visible columns
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
277 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
278 * @returns {int} i the number of visible columns
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
279 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
280 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
281 function _fnVisbleColumns( oSettings )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
282 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
283 return _fnGetColumns( oSettings, 'bVisible' ).length;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
284 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
285
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
286
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
287 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
288 * Get an array of column indexes that match a given property
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
289 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
290 * @param {string} sParam Parameter in aoColumns to look for - typically
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
291 * bVisible or bSearchable
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
292 * @returns {array} Array of indexes with matched properties
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
293 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
294 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
295 function _fnGetColumns( oSettings, sParam )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
296 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
297 var a = [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
298
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
299 $.map( oSettings.aoColumns, function(val, i) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
300 if ( val[sParam] ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
301 a.push( i );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
302 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
303 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
304
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
305 return a;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
306 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
307
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
308
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
309 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
310 * Get the sort type based on an input string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
311 * @param {string} sData data we wish to know the type of
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
312 * @returns {string} type (defaults to 'string' if no type can be detected)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
313 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
314 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
315 function _fnDetectType( sData )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
316 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
317 var aTypes = DataTable.ext.aTypes;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
318 var iLen = aTypes.length;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
319
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
320 for ( var i=0 ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
321 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
322 var sType = aTypes[i]( sData );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
323 if ( sType !== null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
324 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
325 return sType;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
326 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
327 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
328
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
329 return 'string';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
330 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
331
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
332
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
333 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
334 * Figure out how to reorder a display list
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
335 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
336 * @returns array {int} aiReturn index list for reordering
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
337 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
338 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
339 function _fnReOrderIndex ( oSettings, sColumns )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
340 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
341 var aColumns = sColumns.split(',');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
342 var aiReturn = [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
343
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
344 for ( var i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
345 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
346 for ( var j=0 ; j<iLen ; j++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
347 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
348 if ( oSettings.aoColumns[i].sName == aColumns[j] )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
349 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
350 aiReturn.push( j );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
351 break;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
352 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
353 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
354 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
355
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
356 return aiReturn;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
357 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
358
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
359
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
360 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
361 * Get the column ordering that DataTables expects
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
362 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
363 * @returns {string} comma separated list of names
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
364 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
365 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
366 function _fnColumnOrdering ( oSettings )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
367 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
368 var sNames = '';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
369 for ( var i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
370 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
371 sNames += oSettings.aoColumns[i].sName+',';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
372 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
373 if ( sNames.length == iLen )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
374 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
375 return "";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
376 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
377 return sNames.slice(0, -1);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
378 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
379
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
380
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
381 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
382 * Take the column definitions and static columns arrays and calculate how
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
383 * they relate to column indexes. The callback function will then apply the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
384 * definition found for a column to a suitable configuration object.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
385 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
386 * @param {array} aoColDefs The aoColumnDefs array that is to be applied
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
387 * @param {array} aoCols The aoColumns array that defines columns individually
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
388 * @param {function} fn Callback function - takes two parameters, the calculated
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
389 * column index and the definition for that column.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
390 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
391 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
392 function _fnApplyColumnDefs( oSettings, aoColDefs, aoCols, fn )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
393 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
394 var i, iLen, j, jLen, k, kLen;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
395
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
396 // Column definitions with aTargets
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
397 if ( aoColDefs )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
398 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
399 /* Loop over the definitions array - loop in reverse so first instance has priority */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
400 for ( i=aoColDefs.length-1 ; i>=0 ; i-- )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
401 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
402 /* Each definition can target multiple columns, as it is an array */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
403 var aTargets = aoColDefs[i].aTargets;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
404 if ( !$.isArray( aTargets ) )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
405 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
406 _fnLog( oSettings, 1, 'aTargets must be an array of targets, not a '+(typeof aTargets) );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
407 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
408
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
409 for ( j=0, jLen=aTargets.length ; j<jLen ; j++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
410 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
411 if ( typeof aTargets[j] === 'number' && aTargets[j] >= 0 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
412 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
413 /* Add columns that we don't yet know about */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
414 while( oSettings.aoColumns.length <= aTargets[j] )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
415 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
416 _fnAddColumn( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
417 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
418
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
419 /* Integer, basic index */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
420 fn( aTargets[j], aoColDefs[i] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
421 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
422 else if ( typeof aTargets[j] === 'number' && aTargets[j] < 0 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
423 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
424 /* Negative integer, right to left column counting */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
425 fn( oSettings.aoColumns.length+aTargets[j], aoColDefs[i] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
426 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
427 else if ( typeof aTargets[j] === 'string' )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
428 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
429 /* Class name matching on TH element */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
430 for ( k=0, kLen=oSettings.aoColumns.length ; k<kLen ; k++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
431 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
432 if ( aTargets[j] == "_all" ||
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
433 $(oSettings.aoColumns[k].nTh).hasClass( aTargets[j] ) )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
434 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
435 fn( k, aoColDefs[i] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
436 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
437 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
438 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
439 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
440 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
441 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
442
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
443 // Statically defined columns array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
444 if ( aoCols )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
445 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
446 for ( i=0, iLen=aoCols.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
447 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
448 fn( i, aoCols[i] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
449 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
450 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
451 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
452
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
453 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
454 * Add a data array to the table, creating DOM node etc. This is the parallel to
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
455 * _fnGatherData, but for adding rows from a Javascript source, rather than a
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
456 * DOM source.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
457 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
458 * @param {array} aData data array to be added
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
459 * @returns {int} >=0 if successful (index of new aoData entry), -1 if failed
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
460 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
461 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
462 function _fnAddData ( oSettings, aDataSupplied )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
463 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
464 var oCol;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
465
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
466 /* Take an independent copy of the data source so we can bash it about as we wish */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
467 var aDataIn = ($.isArray(aDataSupplied)) ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
468 aDataSupplied.slice() :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
469 $.extend( true, {}, aDataSupplied );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
470
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
471 /* Create the object for storing information about this new row */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
472 var iRow = oSettings.aoData.length;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
473 var oData = $.extend( true, {}, DataTable.models.oRow );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
474 oData._aData = aDataIn;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
475 oSettings.aoData.push( oData );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
476
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
477 /* Create the cells */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
478 var nTd, sThisType;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
479 for ( var i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
480 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
481 oCol = oSettings.aoColumns[i];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
482
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
483 /* Use rendered data for filtering / sorting */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
484 if ( typeof oCol.fnRender === 'function' && oCol.bUseRendered && oCol.mData !== null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
485 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
486 _fnSetCellData( oSettings, iRow, i, _fnRender(oSettings, iRow, i) );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
487 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
488 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
489 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
490 _fnSetCellData( oSettings, iRow, i, _fnGetCellData( oSettings, iRow, i ) );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
491 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
492
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
493 /* See if we should auto-detect the column type */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
494 if ( oCol._bAutoType && oCol.sType != 'string' )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
495 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
496 /* Attempt to auto detect the type - same as _fnGatherData() */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
497 var sVarType = _fnGetCellData( oSettings, iRow, i, 'type' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
498 if ( sVarType !== null && sVarType !== '' )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
499 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
500 sThisType = _fnDetectType( sVarType );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
501 if ( oCol.sType === null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
502 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
503 oCol.sType = sThisType;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
504 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
505 else if ( oCol.sType != sThisType && oCol.sType != "html" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
506 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
507 /* String is always the 'fallback' option */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
508 oCol.sType = 'string';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
509 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
510 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
511 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
512 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
513
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
514 /* Add to the display array */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
515 oSettings.aiDisplayMaster.push( iRow );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
516
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
517 /* Create the DOM information */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
518 if ( !oSettings.oFeatures.bDeferRender )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
519 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
520 _fnCreateTr( oSettings, iRow );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
521 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
522
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
523 return iRow;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
524 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
525
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
526
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
527 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
528 * Read in the data from the target table from the DOM
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
529 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
530 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
531 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
532 function _fnGatherData( oSettings )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
533 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
534 var iLoop, i, iLen, j, jLen, jInner,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
535 nTds, nTrs, nTd, nTr, aLocalData, iThisIndex,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
536 iRow, iRows, iColumn, iColumns, sNodeName,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
537 oCol, oData;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
538
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
539 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
540 * Process by row first
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
541 * Add the data object for the whole table - storing the tr node. Note - no point in getting
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
542 * DOM based data if we are going to go and replace it with Ajax source data.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
543 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
544 if ( oSettings.bDeferLoading || oSettings.sAjaxSource === null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
545 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
546 nTr = oSettings.nTBody.firstChild;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
547 while ( nTr )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
548 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
549 if ( nTr.nodeName.toUpperCase() == "TR" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
550 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
551 iThisIndex = oSettings.aoData.length;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
552 nTr._DT_RowIndex = iThisIndex;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
553 oSettings.aoData.push( $.extend( true, {}, DataTable.models.oRow, {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
554 "nTr": nTr
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
555 } ) );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
556
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
557 oSettings.aiDisplayMaster.push( iThisIndex );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
558 nTd = nTr.firstChild;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
559 jInner = 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
560 while ( nTd )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
561 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
562 sNodeName = nTd.nodeName.toUpperCase();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
563 if ( sNodeName == "TD" || sNodeName == "TH" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
564 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
565 _fnSetCellData( oSettings, iThisIndex, jInner, $.trim(nTd.innerHTML) );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
566 jInner++;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
567 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
568 nTd = nTd.nextSibling;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
569 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
570 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
571 nTr = nTr.nextSibling;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
572 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
573 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
574
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
575 /* Gather in the TD elements of the Table - note that this is basically the same as
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
576 * fnGetTdNodes, but that function takes account of hidden columns, which we haven't yet
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
577 * setup!
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
578 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
579 nTrs = _fnGetTrNodes( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
580 nTds = [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
581 for ( i=0, iLen=nTrs.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
582 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
583 nTd = nTrs[i].firstChild;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
584 while ( nTd )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
585 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
586 sNodeName = nTd.nodeName.toUpperCase();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
587 if ( sNodeName == "TD" || sNodeName == "TH" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
588 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
589 nTds.push( nTd );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
590 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
591 nTd = nTd.nextSibling;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
592 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
593 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
594
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
595 /* Now process by column */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
596 for ( iColumn=0, iColumns=oSettings.aoColumns.length ; iColumn<iColumns ; iColumn++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
597 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
598 oCol = oSettings.aoColumns[iColumn];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
599
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
600 /* Get the title of the column - unless there is a user set one */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
601 if ( oCol.sTitle === null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
602 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
603 oCol.sTitle = oCol.nTh.innerHTML;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
604 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
605
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
606 var
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
607 bAutoType = oCol._bAutoType,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
608 bRender = typeof oCol.fnRender === 'function',
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
609 bClass = oCol.sClass !== null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
610 bVisible = oCol.bVisible,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
611 nCell, sThisType, sRendered, sValType;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
612
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
613 /* A single loop to rule them all (and be more efficient) */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
614 if ( bAutoType || bRender || bClass || !bVisible )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
615 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
616 for ( iRow=0, iRows=oSettings.aoData.length ; iRow<iRows ; iRow++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
617 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
618 oData = oSettings.aoData[iRow];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
619 nCell = nTds[ (iRow*iColumns) + iColumn ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
620
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
621 /* Type detection */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
622 if ( bAutoType && oCol.sType != 'string' )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
623 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
624 sValType = _fnGetCellData( oSettings, iRow, iColumn, 'type' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
625 if ( sValType !== '' )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
626 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
627 sThisType = _fnDetectType( sValType );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
628 if ( oCol.sType === null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
629 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
630 oCol.sType = sThisType;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
631 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
632 else if ( oCol.sType != sThisType &&
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
633 oCol.sType != "html" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
634 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
635 /* String is always the 'fallback' option */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
636 oCol.sType = 'string';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
637 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
638 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
639 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
640
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
641 if ( oCol.mRender )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
642 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
643 // mRender has been defined, so we need to get the value and set it
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
644 nCell.innerHTML = _fnGetCellData( oSettings, iRow, iColumn, 'display' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
645 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
646 else if ( oCol.mData !== iColumn )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
647 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
648 // If mData is not the same as the column number, then we need to
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
649 // get the dev set value. If it is the column, no point in wasting
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
650 // time setting the value that is already there!
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
651 nCell.innerHTML = _fnGetCellData( oSettings, iRow, iColumn, 'display' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
652 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
653
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
654 /* Rendering */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
655 if ( bRender )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
656 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
657 sRendered = _fnRender( oSettings, iRow, iColumn );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
658 nCell.innerHTML = sRendered;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
659 if ( oCol.bUseRendered )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
660 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
661 /* Use the rendered data for filtering / sorting */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
662 _fnSetCellData( oSettings, iRow, iColumn, sRendered );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
663 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
664 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
665
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
666 /* Classes */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
667 if ( bClass )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
668 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
669 nCell.className += ' '+oCol.sClass;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
670 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
671
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
672 /* Column visibility */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
673 if ( !bVisible )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
674 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
675 oData._anHidden[iColumn] = nCell;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
676 nCell.parentNode.removeChild( nCell );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
677 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
678 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
679 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
680 oData._anHidden[iColumn] = null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
681 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
682
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
683 if ( oCol.fnCreatedCell )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
684 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
685 oCol.fnCreatedCell.call( oSettings.oInstance,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
686 nCell, _fnGetCellData( oSettings, iRow, iColumn, 'display' ), oData._aData, iRow, iColumn
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
687 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
688 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
689 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
690 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
691 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
692
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
693 /* Row created callbacks */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
694 if ( oSettings.aoRowCreatedCallback.length !== 0 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
695 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
696 for ( i=0, iLen=oSettings.aoData.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
697 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
698 oData = oSettings.aoData[i];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
699 _fnCallbackFire( oSettings, 'aoRowCreatedCallback', null, [oData.nTr, oData._aData, i] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
700 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
701 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
702 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
703
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
704
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
705 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
706 * Take a TR element and convert it to an index in aoData
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
707 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
708 * @param {node} n the TR element to find
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
709 * @returns {int} index if the node is found, null if not
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
710 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
711 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
712 function _fnNodeToDataIndex( oSettings, n )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
713 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
714 return (n._DT_RowIndex!==undefined) ? n._DT_RowIndex : null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
715 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
716
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
717
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
718 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
719 * Take a TD element and convert it into a column data index (not the visible index)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
720 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
721 * @param {int} iRow The row number the TD/TH can be found in
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
722 * @param {node} n The TD/TH element to find
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
723 * @returns {int} index if the node is found, -1 if not
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
724 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
725 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
726 function _fnNodeToColumnIndex( oSettings, iRow, n )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
727 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
728 var anCells = _fnGetTdNodes( oSettings, iRow );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
729
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
730 for ( var i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
731 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
732 if ( anCells[i] === n )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
733 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
734 return i;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
735 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
736 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
737 return -1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
738 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
739
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
740
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
741 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
742 * Get an array of data for a given row from the internal data cache
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
743 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
744 * @param {int} iRow aoData row id
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
745 * @param {string} sSpecific data get type ('type' 'filter' 'sort')
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
746 * @param {array} aiColumns Array of column indexes to get data from
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
747 * @returns {array} Data array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
748 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
749 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
750 function _fnGetRowData( oSettings, iRow, sSpecific, aiColumns )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
751 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
752 var out = [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
753 for ( var i=0, iLen=aiColumns.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
754 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
755 out.push( _fnGetCellData( oSettings, iRow, aiColumns[i], sSpecific ) );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
756 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
757 return out;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
758 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
759
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
760
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
761 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
762 * Get the data for a given cell from the internal cache, taking into account data mapping
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
763 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
764 * @param {int} iRow aoData row id
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
765 * @param {int} iCol Column index
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
766 * @param {string} sSpecific data get type ('display', 'type' 'filter' 'sort')
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
767 * @returns {*} Cell data
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
768 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
769 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
770 function _fnGetCellData( oSettings, iRow, iCol, sSpecific )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
771 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
772 var sData;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
773 var oCol = oSettings.aoColumns[iCol];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
774 var oData = oSettings.aoData[iRow]._aData;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
775
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
776 if ( (sData=oCol.fnGetData( oData, sSpecific )) === undefined )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
777 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
778 if ( oSettings.iDrawError != oSettings.iDraw && oCol.sDefaultContent === null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
779 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
780 _fnLog( oSettings, 0, "Requested unknown parameter "+
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
781 (typeof oCol.mData=='function' ? '{mData function}' : "'"+oCol.mData+"'")+
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
782 " from the data source for row "+iRow );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
783 oSettings.iDrawError = oSettings.iDraw;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
784 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
785 return oCol.sDefaultContent;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
786 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
787
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
788 /* When the data source is null, we can use default column data */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
789 if ( sData === null && oCol.sDefaultContent !== null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
790 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
791 sData = oCol.sDefaultContent;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
792 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
793 else if ( typeof sData === 'function' )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
794 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
795 /* If the data source is a function, then we run it and use the return */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
796 return sData();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
797 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
798
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
799 if ( sSpecific == 'display' && sData === null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
800 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
801 return '';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
802 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
803 return sData;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
804 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
805
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
806
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
807 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
808 * Set the value for a specific cell, into the internal data cache
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
809 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
810 * @param {int} iRow aoData row id
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
811 * @param {int} iCol Column index
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
812 * @param {*} val Value to set
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
813 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
814 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
815 function _fnSetCellData( oSettings, iRow, iCol, val )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
816 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
817 var oCol = oSettings.aoColumns[iCol];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
818 var oData = oSettings.aoData[iRow]._aData;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
819
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
820 oCol.fnSetData( oData, val );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
821 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
822
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
823
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
824 // Private variable that is used to match array syntax in the data property object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
825 var __reArray = /\[.*?\]$/;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
826
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
827 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
828 * Return a function that can be used to get data from a source object, taking
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
829 * into account the ability to use nested objects as a source
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
830 * @param {string|int|function} mSource The data source for the object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
831 * @returns {function} Data get function
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
832 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
833 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
834 function _fnGetObjectDataFn( mSource )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
835 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
836 if ( mSource === null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
837 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
838 /* Give an empty string for rendering / sorting etc */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
839 return function (data, type) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
840 return null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
841 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
842 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
843 else if ( typeof mSource === 'function' )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
844 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
845 return function (data, type, extra) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
846 return mSource( data, type, extra );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
847 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
848 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
849 else if ( typeof mSource === 'string' && (mSource.indexOf('.') !== -1 || mSource.indexOf('[') !== -1) )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
850 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
851 /* If there is a . in the source string then the data source is in a
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
852 * nested object so we loop over the data for each level to get the next
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
853 * level down. On each loop we test for undefined, and if found immediately
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
854 * return. This allows entire objects to be missing and sDefaultContent to
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
855 * be used if defined, rather than throwing an error
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
856 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
857 var fetchData = function (data, type, src) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
858 var a = src.split('.');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
859 var arrayNotation, out, innerSrc;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
860
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
861 if ( src !== "" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
862 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
863 for ( var i=0, iLen=a.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
864 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
865 // Check if we are dealing with an array notation request
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
866 arrayNotation = a[i].match(__reArray);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
867
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
868 if ( arrayNotation ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
869 a[i] = a[i].replace(__reArray, '');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
870
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
871 // Condition allows simply [] to be passed in
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
872 if ( a[i] !== "" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
873 data = data[ a[i] ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
874 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
875 out = [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
876
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
877 // Get the remainder of the nested object to get
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
878 a.splice( 0, i+1 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
879 innerSrc = a.join('.');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
880
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
881 // Traverse each entry in the array getting the properties requested
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
882 for ( var j=0, jLen=data.length ; j<jLen ; j++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
883 out.push( fetchData( data[j], type, innerSrc ) );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
884 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
885
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
886 // If a string is given in between the array notation indicators, that
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
887 // is used to join the strings together, otherwise an array is returned
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
888 var join = arrayNotation[0].substring(1, arrayNotation[0].length-1);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
889 data = (join==="") ? out : out.join(join);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
890
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
891 // The inner call to fetchData has already traversed through the remainder
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
892 // of the source requested, so we exit from the loop
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
893 break;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
894 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
895
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
896 if ( data === null || data[ a[i] ] === undefined )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
897 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
898 return undefined;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
899 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
900 data = data[ a[i] ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
901 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
902 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
903
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
904 return data;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
905 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
906
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
907 return function (data, type) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
908 return fetchData( data, type, mSource );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
909 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
910 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
911 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
912 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
913 /* Array or flat object mapping */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
914 return function (data, type) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
915 return data[mSource];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
916 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
917 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
918 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
919
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
920
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
921 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
922 * Return a function that can be used to set data from a source object, taking
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
923 * into account the ability to use nested objects as a source
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
924 * @param {string|int|function} mSource The data source for the object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
925 * @returns {function} Data set function
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
926 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
927 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
928 function _fnSetObjectDataFn( mSource )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
929 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
930 if ( mSource === null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
931 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
932 /* Nothing to do when the data source is null */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
933 return function (data, val) {};
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
934 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
935 else if ( typeof mSource === 'function' )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
936 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
937 return function (data, val) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
938 mSource( data, 'set', val );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
939 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
940 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
941 else if ( typeof mSource === 'string' && (mSource.indexOf('.') !== -1 || mSource.indexOf('[') !== -1) )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
942 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
943 /* Like the get, we need to get data from a nested object */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
944 var setData = function (data, val, src) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
945 var a = src.split('.'), b;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
946 var arrayNotation, o, innerSrc;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
947
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
948 for ( var i=0, iLen=a.length-1 ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
949 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
950 // Check if we are dealing with an array notation request
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
951 arrayNotation = a[i].match(__reArray);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
952
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
953 if ( arrayNotation )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
954 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
955 a[i] = a[i].replace(__reArray, '');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
956 data[ a[i] ] = [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
957
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
958 // Get the remainder of the nested object to set so we can recurse
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
959 b = a.slice();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
960 b.splice( 0, i+1 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
961 innerSrc = b.join('.');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
962
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
963 // Traverse each entry in the array setting the properties requested
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
964 for ( var j=0, jLen=val.length ; j<jLen ; j++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
965 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
966 o = {};
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
967 setData( o, val[j], innerSrc );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
968 data[ a[i] ].push( o );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
969 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
970
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
971 // The inner call to setData has already traversed through the remainder
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
972 // of the source and has set the data, thus we can exit here
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
973 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
974 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
975
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
976 // If the nested object doesn't currently exist - since we are
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
977 // trying to set the value - create it
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
978 if ( data[ a[i] ] === null || data[ a[i] ] === undefined )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
979 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
980 data[ a[i] ] = {};
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
981 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
982 data = data[ a[i] ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
983 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
984
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
985 // If array notation is used, we just want to strip it and use the property name
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
986 // and assign the value. If it isn't used, then we get the result we want anyway
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
987 data[ a[a.length-1].replace(__reArray, '') ] = val;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
988 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
989
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
990 return function (data, val) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
991 return setData( data, val, mSource );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
992 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
993 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
994 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
995 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
996 /* Array or flat object mapping */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
997 return function (data, val) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
998 data[mSource] = val;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
999 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1000 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1001 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1002
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1003
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1004 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1005 * Return an array with the full table data
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1006 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1007 * @returns array {array} aData Master data array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1008 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1009 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1010 function _fnGetDataMaster ( oSettings )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1011 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1012 var aData = [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1013 var iLen = oSettings.aoData.length;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1014 for ( var i=0 ; i<iLen; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1015 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1016 aData.push( oSettings.aoData[i]._aData );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1017 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1018 return aData;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1019 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1020
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1021
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1022 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1023 * Nuke the table
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1024 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1025 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1026 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1027 function _fnClearTable( oSettings )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1028 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1029 oSettings.aoData.splice( 0, oSettings.aoData.length );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1030 oSettings.aiDisplayMaster.splice( 0, oSettings.aiDisplayMaster.length );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1031 oSettings.aiDisplay.splice( 0, oSettings.aiDisplay.length );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1032 _fnCalculateEnd( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1033 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1034
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1035
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1036 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1037 * Take an array of integers (index array) and remove a target integer (value - not
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1038 * the key!)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1039 * @param {array} a Index array to target
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1040 * @param {int} iTarget value to find
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1041 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1042 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1043 function _fnDeleteIndex( a, iTarget )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1044 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1045 var iTargetIndex = -1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1046
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1047 for ( var i=0, iLen=a.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1048 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1049 if ( a[i] == iTarget )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1050 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1051 iTargetIndex = i;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1052 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1053 else if ( a[i] > iTarget )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1054 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1055 a[i]--;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1056 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1057 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1058
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1059 if ( iTargetIndex != -1 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1060 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1061 a.splice( iTargetIndex, 1 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1062 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1063 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1064
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1065
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1066 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1067 * Call the developer defined fnRender function for a given cell (row/column) with
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1068 * the required parameters and return the result.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1069 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1070 * @param {int} iRow aoData index for the row
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1071 * @param {int} iCol aoColumns index for the column
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1072 * @returns {*} Return of the developer's fnRender function
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1073 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1074 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1075 function _fnRender( oSettings, iRow, iCol )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1076 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1077 var oCol = oSettings.aoColumns[iCol];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1078
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1079 return oCol.fnRender( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1080 "iDataRow": iRow,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1081 "iDataColumn": iCol,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1082 "oSettings": oSettings,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1083 "aData": oSettings.aoData[iRow]._aData,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1084 "mDataProp": oCol.mData
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1085 }, _fnGetCellData(oSettings, iRow, iCol, 'display') );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1086 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1087 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1088 * Create a new TR element (and it's TD children) for a row
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1089 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1090 * @param {int} iRow Row to consider
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1091 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1092 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1093 function _fnCreateTr ( oSettings, iRow )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1094 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1095 var oData = oSettings.aoData[iRow];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1096 var nTd;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1097
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1098 if ( oData.nTr === null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1099 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1100 oData.nTr = document.createElement('tr');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1101
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1102 /* Use a private property on the node to allow reserve mapping from the node
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1103 * to the aoData array for fast look up
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1104 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1105 oData.nTr._DT_RowIndex = iRow;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1106
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1107 /* Special parameters can be given by the data source to be used on the row */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1108 if ( oData._aData.DT_RowId )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1109 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1110 oData.nTr.id = oData._aData.DT_RowId;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1111 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1112
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1113 if ( oData._aData.DT_RowClass )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1114 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1115 oData.nTr.className = oData._aData.DT_RowClass;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1116 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1117
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1118 /* Process each column */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1119 for ( var i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1120 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1121 var oCol = oSettings.aoColumns[i];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1122 nTd = document.createElement( oCol.sCellType );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1123
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1124 /* Render if needed - if bUseRendered is true then we already have the rendered
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1125 * value in the data source - so can just use that
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1126 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1127 nTd.innerHTML = (typeof oCol.fnRender === 'function' && (!oCol.bUseRendered || oCol.mData === null)) ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1128 _fnRender( oSettings, iRow, i ) :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1129 _fnGetCellData( oSettings, iRow, i, 'display' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1130
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1131 /* Add user defined class */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1132 if ( oCol.sClass !== null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1133 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1134 nTd.className = oCol.sClass;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1135 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1136
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1137 if ( oCol.bVisible )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1138 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1139 oData.nTr.appendChild( nTd );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1140 oData._anHidden[i] = null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1141 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1142 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1143 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1144 oData._anHidden[i] = nTd;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1145 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1146
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1147 if ( oCol.fnCreatedCell )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1148 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1149 oCol.fnCreatedCell.call( oSettings.oInstance,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1150 nTd, _fnGetCellData( oSettings, iRow, i, 'display' ), oData._aData, iRow, i
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1151 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1152 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1153 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1154
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1155 _fnCallbackFire( oSettings, 'aoRowCreatedCallback', null, [oData.nTr, oData._aData, iRow] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1156 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1157 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1158
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1159
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1160 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1161 * Create the HTML header for the table
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1162 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1163 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1164 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1165 function _fnBuildHead( oSettings )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1166 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1167 var i, nTh, iLen, j, jLen;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1168 var iThs = $('th, td', oSettings.nTHead).length;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1169 var iCorrector = 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1170 var jqChildren;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1171
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1172 /* If there is a header in place - then use it - otherwise it's going to get nuked... */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1173 if ( iThs !== 0 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1174 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1175 /* We've got a thead from the DOM, so remove hidden columns and apply width to vis cols */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1176 for ( i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1177 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1178 nTh = oSettings.aoColumns[i].nTh;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1179 nTh.setAttribute('role', 'columnheader');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1180 if ( oSettings.aoColumns[i].bSortable )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1181 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1182 nTh.setAttribute('tabindex', oSettings.iTabIndex);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1183 nTh.setAttribute('aria-controls', oSettings.sTableId);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1184 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1185
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1186 if ( oSettings.aoColumns[i].sClass !== null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1187 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1188 $(nTh).addClass( oSettings.aoColumns[i].sClass );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1189 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1190
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1191 /* Set the title of the column if it is user defined (not what was auto detected) */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1192 if ( oSettings.aoColumns[i].sTitle != nTh.innerHTML )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1193 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1194 nTh.innerHTML = oSettings.aoColumns[i].sTitle;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1195 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1196 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1197 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1198 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1199 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1200 /* We don't have a header in the DOM - so we are going to have to create one */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1201 var nTr = document.createElement( "tr" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1202
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1203 for ( i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1204 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1205 nTh = oSettings.aoColumns[i].nTh;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1206 nTh.innerHTML = oSettings.aoColumns[i].sTitle;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1207 nTh.setAttribute('tabindex', '0');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1208
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1209 if ( oSettings.aoColumns[i].sClass !== null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1210 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1211 $(nTh).addClass( oSettings.aoColumns[i].sClass );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1212 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1213
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1214 nTr.appendChild( nTh );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1215 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1216 $(oSettings.nTHead).html( '' )[0].appendChild( nTr );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1217 _fnDetectHeader( oSettings.aoHeader, oSettings.nTHead );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1218 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1219
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1220 /* ARIA role for the rows */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1221 $(oSettings.nTHead).children('tr').attr('role', 'row');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1222
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1223 /* Add the extra markup needed by jQuery UI's themes */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1224 if ( oSettings.bJUI )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1225 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1226 for ( i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1227 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1228 nTh = oSettings.aoColumns[i].nTh;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1229
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1230 var nDiv = document.createElement('div');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1231 nDiv.className = oSettings.oClasses.sSortJUIWrapper;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1232 $(nTh).contents().appendTo(nDiv);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1233
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1234 var nSpan = document.createElement('span');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1235 nSpan.className = oSettings.oClasses.sSortIcon;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1236 nDiv.appendChild( nSpan );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1237 nTh.appendChild( nDiv );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1238 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1239 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1240
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1241 if ( oSettings.oFeatures.bSort )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1242 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1243 for ( i=0 ; i<oSettings.aoColumns.length ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1244 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1245 if ( oSettings.aoColumns[i].bSortable !== false )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1246 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1247 _fnSortAttachListener( oSettings, oSettings.aoColumns[i].nTh, i );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1248 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1249 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1250 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1251 $(oSettings.aoColumns[i].nTh).addClass( oSettings.oClasses.sSortableNone );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1252 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1253 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1254 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1255
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1256 /* Deal with the footer - add classes if required */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1257 if ( oSettings.oClasses.sFooterTH !== "" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1258 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1259 $(oSettings.nTFoot).children('tr').children('th').addClass( oSettings.oClasses.sFooterTH );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1260 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1261
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1262 /* Cache the footer elements */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1263 if ( oSettings.nTFoot !== null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1264 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1265 var anCells = _fnGetUniqueThs( oSettings, null, oSettings.aoFooter );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1266 for ( i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1267 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1268 if ( anCells[i] )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1269 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1270 oSettings.aoColumns[i].nTf = anCells[i];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1271 if ( oSettings.aoColumns[i].sClass )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1272 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1273 $(anCells[i]).addClass( oSettings.aoColumns[i].sClass );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1274 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1275 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1276 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1277 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1278 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1279
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1280
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1281 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1282 * Draw the header (or footer) element based on the column visibility states. The
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1283 * methodology here is to use the layout array from _fnDetectHeader, modified for
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1284 * the instantaneous column visibility, to construct the new layout. The grid is
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1285 * traversed over cell at a time in a rows x columns grid fashion, although each
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1286 * cell insert can cover multiple elements in the grid - which is tracks using the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1287 * aApplied array. Cell inserts in the grid will only occur where there isn't
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1288 * already a cell in that position.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1289 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1290 * @param array {objects} aoSource Layout array from _fnDetectHeader
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1291 * @param {boolean} [bIncludeHidden=false] If true then include the hidden columns in the calc,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1292 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1293 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1294 function _fnDrawHead( oSettings, aoSource, bIncludeHidden )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1295 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1296 var i, iLen, j, jLen, k, kLen, n, nLocalTr;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1297 var aoLocal = [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1298 var aApplied = [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1299 var iColumns = oSettings.aoColumns.length;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1300 var iRowspan, iColspan;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1301
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1302 if ( bIncludeHidden === undefined )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1303 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1304 bIncludeHidden = false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1305 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1306
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1307 /* Make a copy of the master layout array, but without the visible columns in it */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1308 for ( i=0, iLen=aoSource.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1309 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1310 aoLocal[i] = aoSource[i].slice();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1311 aoLocal[i].nTr = aoSource[i].nTr;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1312
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1313 /* Remove any columns which are currently hidden */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1314 for ( j=iColumns-1 ; j>=0 ; j-- )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1315 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1316 if ( !oSettings.aoColumns[j].bVisible && !bIncludeHidden )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1317 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1318 aoLocal[i].splice( j, 1 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1319 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1320 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1321
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1322 /* Prep the applied array - it needs an element for each row */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1323 aApplied.push( [] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1324 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1325
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1326 for ( i=0, iLen=aoLocal.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1327 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1328 nLocalTr = aoLocal[i].nTr;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1329
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1330 /* All cells are going to be replaced, so empty out the row */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1331 if ( nLocalTr )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1332 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1333 while( (n = nLocalTr.firstChild) )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1334 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1335 nLocalTr.removeChild( n );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1336 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1337 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1338
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1339 for ( j=0, jLen=aoLocal[i].length ; j<jLen ; j++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1340 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1341 iRowspan = 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1342 iColspan = 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1343
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1344 /* Check to see if there is already a cell (row/colspan) covering our target
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1345 * insert point. If there is, then there is nothing to do.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1346 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1347 if ( aApplied[i][j] === undefined )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1348 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1349 nLocalTr.appendChild( aoLocal[i][j].cell );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1350 aApplied[i][j] = 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1351
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1352 /* Expand the cell to cover as many rows as needed */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1353 while ( aoLocal[i+iRowspan] !== undefined &&
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1354 aoLocal[i][j].cell == aoLocal[i+iRowspan][j].cell )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1355 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1356 aApplied[i+iRowspan][j] = 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1357 iRowspan++;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1358 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1359
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1360 /* Expand the cell to cover as many columns as needed */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1361 while ( aoLocal[i][j+iColspan] !== undefined &&
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1362 aoLocal[i][j].cell == aoLocal[i][j+iColspan].cell )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1363 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1364 /* Must update the applied array over the rows for the columns */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1365 for ( k=0 ; k<iRowspan ; k++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1366 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1367 aApplied[i+k][j+iColspan] = 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1368 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1369 iColspan++;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1370 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1371
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1372 /* Do the actual expansion in the DOM */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1373 aoLocal[i][j].cell.rowSpan = iRowspan;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1374 aoLocal[i][j].cell.colSpan = iColspan;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1375 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1376 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1377 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1378 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1379
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1380
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1381 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1382 * Insert the required TR nodes into the table for display
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1383 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1384 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1385 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1386 function _fnDraw( oSettings )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1387 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1388 /* Provide a pre-callback function which can be used to cancel the draw is false is returned */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1389 var aPreDraw = _fnCallbackFire( oSettings, 'aoPreDrawCallback', 'preDraw', [oSettings] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1390 if ( $.inArray( false, aPreDraw ) !== -1 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1391 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1392 _fnProcessingDisplay( oSettings, false );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1393 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1394 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1395
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1396 var i, iLen, n;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1397 var anRows = [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1398 var iRowCount = 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1399 var iStripes = oSettings.asStripeClasses.length;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1400 var iOpenRows = oSettings.aoOpenRows.length;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1401
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1402 oSettings.bDrawing = true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1403
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1404 /* Check and see if we have an initial draw position from state saving */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1405 if ( oSettings.iInitDisplayStart !== undefined && oSettings.iInitDisplayStart != -1 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1406 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1407 if ( oSettings.oFeatures.bServerSide )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1408 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1409 oSettings._iDisplayStart = oSettings.iInitDisplayStart;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1410 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1411 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1412 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1413 oSettings._iDisplayStart = (oSettings.iInitDisplayStart >= oSettings.fnRecordsDisplay()) ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1414 0 : oSettings.iInitDisplayStart;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1415 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1416 oSettings.iInitDisplayStart = -1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1417 _fnCalculateEnd( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1418 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1419
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1420 /* Server-side processing draw intercept */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1421 if ( oSettings.bDeferLoading )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1422 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1423 oSettings.bDeferLoading = false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1424 oSettings.iDraw++;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1425 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1426 else if ( !oSettings.oFeatures.bServerSide )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1427 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1428 oSettings.iDraw++;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1429 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1430 else if ( !oSettings.bDestroying && !_fnAjaxUpdate( oSettings ) )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1431 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1432 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1433 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1434
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1435 if ( oSettings.aiDisplay.length !== 0 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1436 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1437 var iStart = oSettings._iDisplayStart;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1438 var iEnd = oSettings._iDisplayEnd;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1439
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1440 if ( oSettings.oFeatures.bServerSide )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1441 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1442 iStart = 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1443 iEnd = oSettings.aoData.length;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1444 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1445
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1446 for ( var j=iStart ; j<iEnd ; j++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1447 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1448 var aoData = oSettings.aoData[ oSettings.aiDisplay[j] ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1449 if ( aoData.nTr === null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1450 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1451 _fnCreateTr( oSettings, oSettings.aiDisplay[j] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1452 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1453
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1454 var nRow = aoData.nTr;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1455
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1456 /* Remove the old striping classes and then add the new one */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1457 if ( iStripes !== 0 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1458 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1459 var sStripe = oSettings.asStripeClasses[ iRowCount % iStripes ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1460 if ( aoData._sRowStripe != sStripe )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1461 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1462 $(nRow).removeClass( aoData._sRowStripe ).addClass( sStripe );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1463 aoData._sRowStripe = sStripe;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1464 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1465 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1466
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1467 /* Row callback functions - might want to manipulate the row */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1468 _fnCallbackFire( oSettings, 'aoRowCallback', null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1469 [nRow, oSettings.aoData[ oSettings.aiDisplay[j] ]._aData, iRowCount, j] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1470
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1471 anRows.push( nRow );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1472 iRowCount++;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1473
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1474 /* If there is an open row - and it is attached to this parent - attach it on redraw */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1475 if ( iOpenRows !== 0 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1476 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1477 for ( var k=0 ; k<iOpenRows ; k++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1478 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1479 if ( nRow == oSettings.aoOpenRows[k].nParent )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1480 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1481 anRows.push( oSettings.aoOpenRows[k].nTr );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1482 break;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1483 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1484 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1485 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1486 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1487 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1488 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1489 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1490 /* Table is empty - create a row with an empty message in it */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1491 anRows[ 0 ] = document.createElement( 'tr' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1492
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1493 if ( oSettings.asStripeClasses[0] )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1494 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1495 anRows[ 0 ].className = oSettings.asStripeClasses[0];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1496 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1497
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1498 var oLang = oSettings.oLanguage;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1499 var sZero = oLang.sZeroRecords;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1500 if ( oSettings.iDraw == 1 && oSettings.sAjaxSource !== null && !oSettings.oFeatures.bServerSide )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1501 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1502 sZero = oLang.sLoadingRecords;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1503 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1504 else if ( oLang.sEmptyTable && oSettings.fnRecordsTotal() === 0 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1505 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1506 sZero = oLang.sEmptyTable;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1507 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1508
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1509 var nTd = document.createElement( 'td' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1510 nTd.setAttribute( 'valign', "top" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1511 nTd.colSpan = _fnVisbleColumns( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1512 nTd.className = oSettings.oClasses.sRowEmpty;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1513 nTd.innerHTML = _fnInfoMacros( oSettings, sZero );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1514
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1515 anRows[ iRowCount ].appendChild( nTd );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1516 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1517
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1518 /* Header and footer callbacks */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1519 _fnCallbackFire( oSettings, 'aoHeaderCallback', 'header', [ $(oSettings.nTHead).children('tr')[0],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1520 _fnGetDataMaster( oSettings ), oSettings._iDisplayStart, oSettings.fnDisplayEnd(), oSettings.aiDisplay ] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1521
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1522 _fnCallbackFire( oSettings, 'aoFooterCallback', 'footer', [ $(oSettings.nTFoot).children('tr')[0],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1523 _fnGetDataMaster( oSettings ), oSettings._iDisplayStart, oSettings.fnDisplayEnd(), oSettings.aiDisplay ] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1524
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1525 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1526 * Need to remove any old row from the display - note we can't just empty the tbody using
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1527 * $().html('') since this will unbind the jQuery event handlers (even although the node
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1528 * still exists!) - equally we can't use innerHTML, since IE throws an exception.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1529 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1530 var
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1531 nAddFrag = document.createDocumentFragment(),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1532 nRemoveFrag = document.createDocumentFragment(),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1533 nBodyPar, nTrs;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1534
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1535 if ( oSettings.nTBody )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1536 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1537 nBodyPar = oSettings.nTBody.parentNode;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1538 nRemoveFrag.appendChild( oSettings.nTBody );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1539
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1540 /* When doing infinite scrolling, only remove child rows when sorting, filtering or start
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1541 * up. When not infinite scroll, always do it.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1542 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1543 if ( !oSettings.oScroll.bInfinite || !oSettings._bInitComplete ||
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1544 oSettings.bSorted || oSettings.bFiltered )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1545 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1546 while( (n = oSettings.nTBody.firstChild) )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1547 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1548 oSettings.nTBody.removeChild( n );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1549 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1550 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1551
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1552 /* Put the draw table into the dom */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1553 for ( i=0, iLen=anRows.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1554 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1555 nAddFrag.appendChild( anRows[i] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1556 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1557
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1558 oSettings.nTBody.appendChild( nAddFrag );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1559 if ( nBodyPar !== null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1560 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1561 nBodyPar.appendChild( oSettings.nTBody );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1562 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1563 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1564
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1565 /* Call all required callback functions for the end of a draw */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1566 _fnCallbackFire( oSettings, 'aoDrawCallback', 'draw', [oSettings] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1567
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1568 /* Draw is complete, sorting and filtering must be as well */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1569 oSettings.bSorted = false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1570 oSettings.bFiltered = false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1571 oSettings.bDrawing = false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1572
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1573 if ( oSettings.oFeatures.bServerSide )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1574 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1575 _fnProcessingDisplay( oSettings, false );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1576 if ( !oSettings._bInitComplete )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1577 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1578 _fnInitComplete( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1579 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1580 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1581 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1582
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1583
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1584 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1585 * Redraw the table - taking account of the various features which are enabled
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1586 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1587 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1588 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1589 function _fnReDraw( oSettings )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1590 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1591 if ( oSettings.oFeatures.bSort )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1592 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1593 /* Sorting will refilter and draw for us */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1594 _fnSort( oSettings, oSettings.oPreviousSearch );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1595 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1596 else if ( oSettings.oFeatures.bFilter )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1597 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1598 /* Filtering will redraw for us */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1599 _fnFilterComplete( oSettings, oSettings.oPreviousSearch );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1600 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1601 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1602 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1603 _fnCalculateEnd( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1604 _fnDraw( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1605 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1606 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1607
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1608
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1609 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1610 * Add the options to the page HTML for the table
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1611 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1612 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1613 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1614 function _fnAddOptionsHtml ( oSettings )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1615 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1616 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1617 * Create a temporary, empty, div which we can later on replace with what we have generated
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1618 * we do it this way to rendering the 'options' html offline - speed :-)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1619 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1620 var nHolding = $('<div></div>')[0];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1621 oSettings.nTable.parentNode.insertBefore( nHolding, oSettings.nTable );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1622
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1623 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1624 * All DataTables are wrapped in a div
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1625 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1626 oSettings.nTableWrapper = $('<div id="'+oSettings.sTableId+'_wrapper" class="'+oSettings.oClasses.sWrapper+'" role="grid"></div>')[0];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1627 oSettings.nTableReinsertBefore = oSettings.nTable.nextSibling;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1628
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1629 /* Track where we want to insert the option */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1630 var nInsertNode = oSettings.nTableWrapper;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1631
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1632 /* Loop over the user set positioning and place the elements as needed */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1633 var aDom = oSettings.sDom.split('');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1634 var nTmp, iPushFeature, cOption, nNewNode, cNext, sAttr, j;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1635 for ( var i=0 ; i<aDom.length ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1636 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1637 iPushFeature = 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1638 cOption = aDom[i];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1639
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1640 if ( cOption == '<' )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1641 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1642 /* New container div */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1643 nNewNode = $('<div></div>')[0];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1644
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1645 /* Check to see if we should append an id and/or a class name to the container */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1646 cNext = aDom[i+1];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1647 if ( cNext == "'" || cNext == '"' )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1648 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1649 sAttr = "";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1650 j = 2;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1651 while ( aDom[i+j] != cNext )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1652 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1653 sAttr += aDom[i+j];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1654 j++;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1655 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1656
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1657 /* Replace jQuery UI constants */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1658 if ( sAttr == "H" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1659 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1660 sAttr = oSettings.oClasses.sJUIHeader;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1661 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1662 else if ( sAttr == "F" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1663 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1664 sAttr = oSettings.oClasses.sJUIFooter;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1665 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1666
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1667 /* The attribute can be in the format of "#id.class", "#id" or "class" This logic
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1668 * breaks the string into parts and applies them as needed
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1669 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1670 if ( sAttr.indexOf('.') != -1 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1671 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1672 var aSplit = sAttr.split('.');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1673 nNewNode.id = aSplit[0].substr(1, aSplit[0].length-1);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1674 nNewNode.className = aSplit[1];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1675 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1676 else if ( sAttr.charAt(0) == "#" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1677 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1678 nNewNode.id = sAttr.substr(1, sAttr.length-1);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1679 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1680 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1681 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1682 nNewNode.className = sAttr;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1683 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1684
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1685 i += j; /* Move along the position array */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1686 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1687
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1688 nInsertNode.appendChild( nNewNode );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1689 nInsertNode = nNewNode;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1690 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1691 else if ( cOption == '>' )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1692 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1693 /* End container div */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1694 nInsertNode = nInsertNode.parentNode;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1695 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1696 else if ( cOption == 'l' && oSettings.oFeatures.bPaginate && oSettings.oFeatures.bLengthChange )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1697 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1698 /* Length */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1699 nTmp = _fnFeatureHtmlLength( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1700 iPushFeature = 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1701 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1702 else if ( cOption == 'f' && oSettings.oFeatures.bFilter )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1703 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1704 /* Filter */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1705 nTmp = _fnFeatureHtmlFilter( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1706 iPushFeature = 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1707 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1708 else if ( cOption == 'r' && oSettings.oFeatures.bProcessing )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1709 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1710 /* pRocessing */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1711 nTmp = _fnFeatureHtmlProcessing( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1712 iPushFeature = 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1713 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1714 else if ( cOption == 't' )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1715 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1716 /* Table */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1717 nTmp = _fnFeatureHtmlTable( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1718 iPushFeature = 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1719 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1720 else if ( cOption == 'i' && oSettings.oFeatures.bInfo )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1721 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1722 /* Info */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1723 nTmp = _fnFeatureHtmlInfo( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1724 iPushFeature = 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1725 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1726 else if ( cOption == 'p' && oSettings.oFeatures.bPaginate )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1727 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1728 /* Pagination */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1729 nTmp = _fnFeatureHtmlPaginate( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1730 iPushFeature = 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1731 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1732 else if ( DataTable.ext.aoFeatures.length !== 0 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1733 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1734 /* Plug-in features */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1735 var aoFeatures = DataTable.ext.aoFeatures;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1736 for ( var k=0, kLen=aoFeatures.length ; k<kLen ; k++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1737 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1738 if ( cOption == aoFeatures[k].cFeature )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1739 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1740 nTmp = aoFeatures[k].fnInit( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1741 if ( nTmp )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1742 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1743 iPushFeature = 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1744 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1745 break;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1746 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1747 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1748 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1749
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1750 /* Add to the 2D features array */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1751 if ( iPushFeature == 1 && nTmp !== null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1752 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1753 if ( typeof oSettings.aanFeatures[cOption] !== 'object' )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1754 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1755 oSettings.aanFeatures[cOption] = [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1756 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1757 oSettings.aanFeatures[cOption].push( nTmp );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1758 nInsertNode.appendChild( nTmp );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1759 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1760 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1761
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1762 /* Built our DOM structure - replace the holding div with what we want */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1763 nHolding.parentNode.replaceChild( oSettings.nTableWrapper, nHolding );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1764 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1765
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1766
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1767 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1768 * Use the DOM source to create up an array of header cells. The idea here is to
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1769 * create a layout grid (array) of rows x columns, which contains a reference
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1770 * to the cell that that point in the grid (regardless of col/rowspan), such that
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1771 * any column / row could be removed and the new grid constructed
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1772 * @param array {object} aLayout Array to store the calculated layout in
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1773 * @param {node} nThead The header/footer element for the table
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1774 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1775 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1776 function _fnDetectHeader ( aLayout, nThead )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1777 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1778 var nTrs = $(nThead).children('tr');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1779 var nTr, nCell;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1780 var i, k, l, iLen, jLen, iColShifted, iColumn, iColspan, iRowspan;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1781 var bUnique;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1782 var fnShiftCol = function ( a, i, j ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1783 var k = a[i];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1784 while ( k[j] ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1785 j++;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1786 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1787 return j;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1788 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1789
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1790 aLayout.splice( 0, aLayout.length );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1791
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1792 /* We know how many rows there are in the layout - so prep it */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1793 for ( i=0, iLen=nTrs.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1794 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1795 aLayout.push( [] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1796 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1797
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1798 /* Calculate a layout array */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1799 for ( i=0, iLen=nTrs.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1800 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1801 nTr = nTrs[i];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1802 iColumn = 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1803
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1804 /* For every cell in the row... */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1805 nCell = nTr.firstChild;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1806 while ( nCell ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1807 if ( nCell.nodeName.toUpperCase() == "TD" ||
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1808 nCell.nodeName.toUpperCase() == "TH" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1809 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1810 /* Get the col and rowspan attributes from the DOM and sanitise them */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1811 iColspan = nCell.getAttribute('colspan') * 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1812 iRowspan = nCell.getAttribute('rowspan') * 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1813 iColspan = (!iColspan || iColspan===0 || iColspan===1) ? 1 : iColspan;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1814 iRowspan = (!iRowspan || iRowspan===0 || iRowspan===1) ? 1 : iRowspan;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1815
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1816 /* There might be colspan cells already in this row, so shift our target
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1817 * accordingly
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1818 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1819 iColShifted = fnShiftCol( aLayout, i, iColumn );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1820
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1821 /* Cache calculation for unique columns */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1822 bUnique = iColspan === 1 ? true : false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1823
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1824 /* If there is col / rowspan, copy the information into the layout grid */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1825 for ( l=0 ; l<iColspan ; l++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1826 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1827 for ( k=0 ; k<iRowspan ; k++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1828 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1829 aLayout[i+k][iColShifted+l] = {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1830 "cell": nCell,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1831 "unique": bUnique
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1832 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1833 aLayout[i+k].nTr = nTr;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1834 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1835 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1836 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1837 nCell = nCell.nextSibling;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1838 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1839 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1840 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1841
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1842
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1843 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1844 * Get an array of unique th elements, one for each column
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1845 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1846 * @param {node} nHeader automatically detect the layout from this node - optional
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1847 * @param {array} aLayout thead/tfoot layout from _fnDetectHeader - optional
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1848 * @returns array {node} aReturn list of unique th's
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1849 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1850 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1851 function _fnGetUniqueThs ( oSettings, nHeader, aLayout )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1852 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1853 var aReturn = [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1854 if ( !aLayout )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1855 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1856 aLayout = oSettings.aoHeader;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1857 if ( nHeader )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1858 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1859 aLayout = [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1860 _fnDetectHeader( aLayout, nHeader );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1861 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1862 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1863
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1864 for ( var i=0, iLen=aLayout.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1865 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1866 for ( var j=0, jLen=aLayout[i].length ; j<jLen ; j++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1867 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1868 if ( aLayout[i][j].unique &&
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1869 (!aReturn[j] || !oSettings.bSortCellsTop) )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1870 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1871 aReturn[j] = aLayout[i][j].cell;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1872 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1873 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1874 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1875
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1876 return aReturn;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1877 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1878
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1879
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1880
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1881 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1882 * Update the table using an Ajax call
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1883 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1884 * @returns {boolean} Block the table drawing or not
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1885 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1886 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1887 function _fnAjaxUpdate( oSettings )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1888 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1889 if ( oSettings.bAjaxDataGet )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1890 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1891 oSettings.iDraw++;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1892 _fnProcessingDisplay( oSettings, true );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1893 var iColumns = oSettings.aoColumns.length;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1894 var aoData = _fnAjaxParameters( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1895 _fnServerParams( oSettings, aoData );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1896
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1897 oSettings.fnServerData.call( oSettings.oInstance, oSettings.sAjaxSource, aoData,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1898 function(json) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1899 _fnAjaxUpdateDraw( oSettings, json );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1900 }, oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1901 return false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1902 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1903 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1904 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1905 return true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1906 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1907 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1908
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1909
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1910 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1911 * Build up the parameters in an object needed for a server-side processing request
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1912 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1913 * @returns {bool} block the table drawing or not
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1914 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1915 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1916 function _fnAjaxParameters( oSettings )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1917 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1918 var iColumns = oSettings.aoColumns.length;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1919 var aoData = [], mDataProp, aaSort, aDataSort;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1920 var i, j;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1921
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1922 aoData.push( { "name": "sEcho", "value": oSettings.iDraw } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1923 aoData.push( { "name": "iColumns", "value": iColumns } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1924 aoData.push( { "name": "sColumns", "value": _fnColumnOrdering(oSettings) } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1925 aoData.push( { "name": "iDisplayStart", "value": oSettings._iDisplayStart } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1926 aoData.push( { "name": "iDisplayLength", "value": oSettings.oFeatures.bPaginate !== false ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1927 oSettings._iDisplayLength : -1 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1928
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1929 for ( i=0 ; i<iColumns ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1930 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1931 mDataProp = oSettings.aoColumns[i].mData;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1932 aoData.push( { "name": "mDataProp_"+i, "value": typeof(mDataProp)==="function" ? 'function' : mDataProp } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1933 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1934
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1935 /* Filtering */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1936 if ( oSettings.oFeatures.bFilter !== false )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1937 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1938 aoData.push( { "name": "sSearch", "value": oSettings.oPreviousSearch.sSearch } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1939 aoData.push( { "name": "bRegex", "value": oSettings.oPreviousSearch.bRegex } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1940 for ( i=0 ; i<iColumns ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1941 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1942 aoData.push( { "name": "sSearch_"+i, "value": oSettings.aoPreSearchCols[i].sSearch } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1943 aoData.push( { "name": "bRegex_"+i, "value": oSettings.aoPreSearchCols[i].bRegex } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1944 aoData.push( { "name": "bSearchable_"+i, "value": oSettings.aoColumns[i].bSearchable } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1945 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1946 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1947
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1948 /* Sorting */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1949 if ( oSettings.oFeatures.bSort !== false )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1950 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1951 var iCounter = 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1952
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1953 aaSort = ( oSettings.aaSortingFixed !== null ) ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1954 oSettings.aaSortingFixed.concat( oSettings.aaSorting ) :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1955 oSettings.aaSorting.slice();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1956
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1957 for ( i=0 ; i<aaSort.length ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1958 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1959 aDataSort = oSettings.aoColumns[ aaSort[i][0] ].aDataSort;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1960
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1961 for ( j=0 ; j<aDataSort.length ; j++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1962 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1963 aoData.push( { "name": "iSortCol_"+iCounter, "value": aDataSort[j] } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1964 aoData.push( { "name": "sSortDir_"+iCounter, "value": aaSort[i][1] } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1965 iCounter++;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1966 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1967 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1968 aoData.push( { "name": "iSortingCols", "value": iCounter } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1969
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1970 for ( i=0 ; i<iColumns ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1971 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1972 aoData.push( { "name": "bSortable_"+i, "value": oSettings.aoColumns[i].bSortable } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1973 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1974 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1975
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1976 return aoData;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1977 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1978
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1979
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1980 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1981 * Add Ajax parameters from plug-ins
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1982 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1983 * @param array {objects} aoData name/value pairs to send to the server
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1984 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1985 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1986 function _fnServerParams( oSettings, aoData )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1987 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1988 _fnCallbackFire( oSettings, 'aoServerParams', 'serverParams', [aoData] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1989 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1990
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1991
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1992 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1993 * Data the data from the server (nuking the old) and redraw the table
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1994 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1995 * @param {object} json json data return from the server.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1996 * @param {string} json.sEcho Tracking flag for DataTables to match requests
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1997 * @param {int} json.iTotalRecords Number of records in the data set, not accounting for filtering
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1998 * @param {int} json.iTotalDisplayRecords Number of records in the data set, accounting for filtering
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1999 * @param {array} json.aaData The data to display on this page
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2000 * @param {string} [json.sColumns] Column ordering (sName, comma separated)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2001 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2002 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2003 function _fnAjaxUpdateDraw ( oSettings, json )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2004 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2005 if ( json.sEcho !== undefined )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2006 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2007 /* Protect against old returns over-writing a new one. Possible when you get
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2008 * very fast interaction, and later queries are completed much faster
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2009 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2010 if ( json.sEcho*1 < oSettings.iDraw )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2011 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2012 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2013 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2014 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2015 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2016 oSettings.iDraw = json.sEcho * 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2017 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2018 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2019
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2020 if ( !oSettings.oScroll.bInfinite ||
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2021 (oSettings.oScroll.bInfinite && (oSettings.bSorted || oSettings.bFiltered)) )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2022 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2023 _fnClearTable( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2024 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2025 oSettings._iRecordsTotal = parseInt(json.iTotalRecords, 10);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2026 oSettings._iRecordsDisplay = parseInt(json.iTotalDisplayRecords, 10);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2027
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2028 /* Determine if reordering is required */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2029 var sOrdering = _fnColumnOrdering(oSettings);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2030 var bReOrder = (json.sColumns !== undefined && sOrdering !== "" && json.sColumns != sOrdering );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2031 var aiIndex;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2032 if ( bReOrder )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2033 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2034 aiIndex = _fnReOrderIndex( oSettings, json.sColumns );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2035 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2036
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2037 var aData = _fnGetObjectDataFn( oSettings.sAjaxDataProp )( json );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2038 for ( var i=0, iLen=aData.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2039 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2040 if ( bReOrder )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2041 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2042 /* If we need to re-order, then create a new array with the correct order and add it */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2043 var aDataSorted = [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2044 for ( var j=0, jLen=oSettings.aoColumns.length ; j<jLen ; j++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2045 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2046 aDataSorted.push( aData[i][ aiIndex[j] ] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2047 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2048 _fnAddData( oSettings, aDataSorted );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2049 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2050 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2051 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2052 /* No re-order required, sever got it "right" - just straight add */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2053 _fnAddData( oSettings, aData[i] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2054 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2055 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2056 oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2057
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2058 oSettings.bAjaxDataGet = false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2059 _fnDraw( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2060 oSettings.bAjaxDataGet = true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2061 _fnProcessingDisplay( oSettings, false );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2062 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2063
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2064
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2065
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2066 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2067 * Generate the node required for filtering text
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2068 * @returns {node} Filter control element
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2069 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2070 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2071 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2072 function _fnFeatureHtmlFilter ( oSettings )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2073 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2074 var oPreviousSearch = oSettings.oPreviousSearch;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2075
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2076 var sSearchStr = oSettings.oLanguage.sSearch;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2077 sSearchStr = (sSearchStr.indexOf('_INPUT_') !== -1) ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2078 sSearchStr.replace('_INPUT_', '<input type="text" />') :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2079 sSearchStr==="" ? '<input type="text" />' : sSearchStr+' <input type="text" />';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2080
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2081 var nFilter = document.createElement( 'div' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2082 nFilter.className = oSettings.oClasses.sFilter;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2083 nFilter.innerHTML = '<label>'+sSearchStr+'</label>';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2084 if ( !oSettings.aanFeatures.f )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2085 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2086 nFilter.id = oSettings.sTableId+'_filter';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2087 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2088
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2089 var jqFilter = $('input[type="text"]', nFilter);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2090
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2091 // Store a reference to the input element, so other input elements could be
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2092 // added to the filter wrapper if needed (submit button for example)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2093 nFilter._DT_Input = jqFilter[0];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2094
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2095 jqFilter.val( oPreviousSearch.sSearch.replace('"','&quot;') );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2096 jqFilter.bind( 'keyup.DT', function(e) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2097 /* Update all other filter input elements for the new display */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2098 var n = oSettings.aanFeatures.f;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2099 var val = this.value==="" ? "" : this.value; // mental IE8 fix :-(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2100
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2101 for ( var i=0, iLen=n.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2102 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2103 if ( n[i] != $(this).parents('div.dataTables_filter')[0] )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2104 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2105 $(n[i]._DT_Input).val( val );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2106 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2107 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2108
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2109 /* Now do the filter */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2110 if ( val != oPreviousSearch.sSearch )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2111 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2112 _fnFilterComplete( oSettings, {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2113 "sSearch": val,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2114 "bRegex": oPreviousSearch.bRegex,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2115 "bSmart": oPreviousSearch.bSmart ,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2116 "bCaseInsensitive": oPreviousSearch.bCaseInsensitive
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2117 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2118 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2119 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2120
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2121 jqFilter
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2122 .attr('aria-controls', oSettings.sTableId)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2123 .bind( 'keypress.DT', function(e) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2124 /* Prevent form submission */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2125 if ( e.keyCode == 13 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2126 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2127 return false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2128 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2129 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2130 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2131
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2132 return nFilter;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2133 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2134
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2135
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2136 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2137 * Filter the table using both the global filter and column based filtering
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2138 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2139 * @param {object} oSearch search information
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2140 * @param {int} [iForce] force a research of the master array (1) or not (undefined or 0)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2141 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2142 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2143 function _fnFilterComplete ( oSettings, oInput, iForce )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2144 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2145 var oPrevSearch = oSettings.oPreviousSearch;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2146 var aoPrevSearch = oSettings.aoPreSearchCols;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2147 var fnSaveFilter = function ( oFilter ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2148 /* Save the filtering values */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2149 oPrevSearch.sSearch = oFilter.sSearch;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2150 oPrevSearch.bRegex = oFilter.bRegex;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2151 oPrevSearch.bSmart = oFilter.bSmart;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2152 oPrevSearch.bCaseInsensitive = oFilter.bCaseInsensitive;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2153 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2154
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2155 /* In server-side processing all filtering is done by the server, so no point hanging around here */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2156 if ( !oSettings.oFeatures.bServerSide )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2157 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2158 /* Global filter */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2159 _fnFilter( oSettings, oInput.sSearch, iForce, oInput.bRegex, oInput.bSmart, oInput.bCaseInsensitive );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2160 fnSaveFilter( oInput );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2161
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2162 /* Now do the individual column filter */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2163 for ( var i=0 ; i<oSettings.aoPreSearchCols.length ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2164 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2165 _fnFilterColumn( oSettings, aoPrevSearch[i].sSearch, i, aoPrevSearch[i].bRegex,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2166 aoPrevSearch[i].bSmart, aoPrevSearch[i].bCaseInsensitive );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2167 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2168
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2169 /* Custom filtering */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2170 _fnFilterCustom( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2171 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2172 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2173 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2174 fnSaveFilter( oInput );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2175 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2176
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2177 /* Tell the draw function we have been filtering */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2178 oSettings.bFiltered = true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2179 $(oSettings.oInstance).trigger('filter', oSettings);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2180
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2181 /* Redraw the table */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2182 oSettings._iDisplayStart = 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2183 _fnCalculateEnd( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2184 _fnDraw( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2185
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2186 /* Rebuild search array 'offline' */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2187 _fnBuildSearchArray( oSettings, 0 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2188 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2189
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2190
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2191 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2192 * Apply custom filtering functions
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2193 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2194 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2195 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2196 function _fnFilterCustom( oSettings )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2197 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2198 var afnFilters = DataTable.ext.afnFiltering;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2199 var aiFilterColumns = _fnGetColumns( oSettings, 'bSearchable' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2200
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2201 for ( var i=0, iLen=afnFilters.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2202 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2203 var iCorrector = 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2204 for ( var j=0, jLen=oSettings.aiDisplay.length ; j<jLen ; j++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2205 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2206 var iDisIndex = oSettings.aiDisplay[j-iCorrector];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2207 var bTest = afnFilters[i](
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2208 oSettings,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2209 _fnGetRowData( oSettings, iDisIndex, 'filter', aiFilterColumns ),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2210 iDisIndex
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2211 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2212
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2213 /* Check if we should use this row based on the filtering function */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2214 if ( !bTest )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2215 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2216 oSettings.aiDisplay.splice( j-iCorrector, 1 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2217 iCorrector++;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2218 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2219 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2220 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2221 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2222
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2223
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2224 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2225 * Filter the table on a per-column basis
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2226 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2227 * @param {string} sInput string to filter on
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2228 * @param {int} iColumn column to filter
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2229 * @param {bool} bRegex treat search string as a regular expression or not
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2230 * @param {bool} bSmart use smart filtering or not
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2231 * @param {bool} bCaseInsensitive Do case insenstive matching or not
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2232 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2233 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2234 function _fnFilterColumn ( oSettings, sInput, iColumn, bRegex, bSmart, bCaseInsensitive )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2235 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2236 if ( sInput === "" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2237 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2238 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2239 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2240
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2241 var iIndexCorrector = 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2242 var rpSearch = _fnFilterCreateSearch( sInput, bRegex, bSmart, bCaseInsensitive );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2243
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2244 for ( var i=oSettings.aiDisplay.length-1 ; i>=0 ; i-- )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2245 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2246 var sData = _fnDataToSearch( _fnGetCellData( oSettings, oSettings.aiDisplay[i], iColumn, 'filter' ),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2247 oSettings.aoColumns[iColumn].sType );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2248 if ( ! rpSearch.test( sData ) )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2249 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2250 oSettings.aiDisplay.splice( i, 1 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2251 iIndexCorrector++;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2252 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2253 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2254 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2255
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2256
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2257 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2258 * Filter the data table based on user input and draw the table
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2259 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2260 * @param {string} sInput string to filter on
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2261 * @param {int} iForce optional - force a research of the master array (1) or not (undefined or 0)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2262 * @param {bool} bRegex treat as a regular expression or not
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2263 * @param {bool} bSmart perform smart filtering or not
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2264 * @param {bool} bCaseInsensitive Do case insenstive matching or not
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2265 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2266 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2267 function _fnFilter( oSettings, sInput, iForce, bRegex, bSmart, bCaseInsensitive )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2268 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2269 var i;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2270 var rpSearch = _fnFilterCreateSearch( sInput, bRegex, bSmart, bCaseInsensitive );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2271 var oPrevSearch = oSettings.oPreviousSearch;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2272
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2273 /* Check if we are forcing or not - optional parameter */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2274 if ( !iForce )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2275 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2276 iForce = 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2277 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2278
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2279 /* Need to take account of custom filtering functions - always filter */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2280 if ( DataTable.ext.afnFiltering.length !== 0 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2281 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2282 iForce = 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2283 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2284
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2285 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2286 * If the input is blank - we want the full data set
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2287 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2288 if ( sInput.length <= 0 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2289 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2290 oSettings.aiDisplay.splice( 0, oSettings.aiDisplay.length);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2291 oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2292 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2293 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2294 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2295 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2296 * We are starting a new search or the new search string is smaller
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2297 * then the old one (i.e. delete). Search from the master array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2298 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2299 if ( oSettings.aiDisplay.length == oSettings.aiDisplayMaster.length ||
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2300 oPrevSearch.sSearch.length > sInput.length || iForce == 1 ||
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2301 sInput.indexOf(oPrevSearch.sSearch) !== 0 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2302 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2303 /* Nuke the old display array - we are going to rebuild it */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2304 oSettings.aiDisplay.splice( 0, oSettings.aiDisplay.length);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2305
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2306 /* Force a rebuild of the search array */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2307 _fnBuildSearchArray( oSettings, 1 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2308
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2309 /* Search through all records to populate the search array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2310 * The the oSettings.aiDisplayMaster and asDataSearch arrays have 1 to 1
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2311 * mapping
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2312 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2313 for ( i=0 ; i<oSettings.aiDisplayMaster.length ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2314 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2315 if ( rpSearch.test(oSettings.asDataSearch[i]) )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2316 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2317 oSettings.aiDisplay.push( oSettings.aiDisplayMaster[i] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2318 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2319 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2320 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2321 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2322 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2323 /* Using old search array - refine it - do it this way for speed
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2324 * Don't have to search the whole master array again
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2325 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2326 var iIndexCorrector = 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2327
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2328 /* Search the current results */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2329 for ( i=0 ; i<oSettings.asDataSearch.length ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2330 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2331 if ( ! rpSearch.test(oSettings.asDataSearch[i]) )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2332 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2333 oSettings.aiDisplay.splice( i-iIndexCorrector, 1 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2334 iIndexCorrector++;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2335 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2336 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2337 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2338 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2339 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2340
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2341
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2342 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2343 * Create an array which can be quickly search through
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2344 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2345 * @param {int} iMaster use the master data array - optional
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2346 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2347 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2348 function _fnBuildSearchArray ( oSettings, iMaster )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2349 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2350 if ( !oSettings.oFeatures.bServerSide )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2351 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2352 /* Clear out the old data */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2353 oSettings.asDataSearch = [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2354
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2355 var aiFilterColumns = _fnGetColumns( oSettings, 'bSearchable' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2356 var aiIndex = (iMaster===1) ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2357 oSettings.aiDisplayMaster :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2358 oSettings.aiDisplay;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2359
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2360 for ( var i=0, iLen=aiIndex.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2361 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2362 oSettings.asDataSearch[i] = _fnBuildSearchRow(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2363 oSettings,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2364 _fnGetRowData( oSettings, aiIndex[i], 'filter', aiFilterColumns )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2365 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2366 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2367 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2368 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2369
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2370
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2371 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2372 * Create a searchable string from a single data row
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2373 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2374 * @param {array} aData Row data array to use for the data to search
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2375 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2376 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2377 function _fnBuildSearchRow( oSettings, aData )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2378 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2379 var sSearch = aData.join(' ');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2380
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2381 /* If it looks like there is an HTML entity in the string, attempt to decode it */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2382 if ( sSearch.indexOf('&') !== -1 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2383 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2384 sSearch = $('<div>').html(sSearch).text();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2385 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2386
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2387 // Strip newline characters
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2388 return sSearch.replace( /[\n\r]/g, " " );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2389 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2390
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2391 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2392 * Build a regular expression object suitable for searching a table
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2393 * @param {string} sSearch string to search for
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2394 * @param {bool} bRegex treat as a regular expression or not
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2395 * @param {bool} bSmart perform smart filtering or not
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2396 * @param {bool} bCaseInsensitive Do case insensitive matching or not
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2397 * @returns {RegExp} constructed object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2398 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2399 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2400 function _fnFilterCreateSearch( sSearch, bRegex, bSmart, bCaseInsensitive )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2401 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2402 var asSearch, sRegExpString;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2403
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2404 if ( bSmart )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2405 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2406 /* Generate the regular expression to use. Something along the lines of:
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2407 * ^(?=.*?\bone\b)(?=.*?\btwo\b)(?=.*?\bthree\b).*$
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2408 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2409 asSearch = bRegex ? sSearch.split( ' ' ) : _fnEscapeRegex( sSearch ).split( ' ' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2410 sRegExpString = '^(?=.*?'+asSearch.join( ')(?=.*?' )+').*$';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2411 return new RegExp( sRegExpString, bCaseInsensitive ? "i" : "" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2412 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2413 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2414 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2415 sSearch = bRegex ? sSearch : _fnEscapeRegex( sSearch );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2416 return new RegExp( sSearch, bCaseInsensitive ? "i" : "" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2417 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2418 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2419
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2420
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2421 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2422 * Convert raw data into something that the user can search on
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2423 * @param {string} sData data to be modified
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2424 * @param {string} sType data type
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2425 * @returns {string} search string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2426 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2427 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2428 function _fnDataToSearch ( sData, sType )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2429 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2430 if ( typeof DataTable.ext.ofnSearch[sType] === "function" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2431 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2432 return DataTable.ext.ofnSearch[sType]( sData );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2433 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2434 else if ( sData === null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2435 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2436 return '';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2437 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2438 else if ( sType == "html" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2439 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2440 return sData.replace(/[\r\n]/g," ").replace( /<.*?>/g, "" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2441 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2442 else if ( typeof sData === "string" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2443 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2444 return sData.replace(/[\r\n]/g," ");
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2445 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2446 return sData;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2447 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2448
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2449
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2450 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2451 * scape a string such that it can be used in a regular expression
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2452 * @param {string} sVal string to escape
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2453 * @returns {string} escaped string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2454 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2455 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2456 function _fnEscapeRegex ( sVal )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2457 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2458 var acEscape = [ '/', '.', '*', '+', '?', '|', '(', ')', '[', ']', '{', '}', '\\', '$', '^', '-' ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2459 var reReplace = new RegExp( '(\\' + acEscape.join('|\\') + ')', 'g' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2460 return sVal.replace(reReplace, '\\$1');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2461 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2462
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2463
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2464 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2465 * Generate the node required for the info display
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2466 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2467 * @returns {node} Information element
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2468 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2469 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2470 function _fnFeatureHtmlInfo ( oSettings )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2471 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2472 var nInfo = document.createElement( 'div' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2473 nInfo.className = oSettings.oClasses.sInfo;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2474
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2475 /* Actions that are to be taken once only for this feature */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2476 if ( !oSettings.aanFeatures.i )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2477 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2478 /* Add draw callback */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2479 oSettings.aoDrawCallback.push( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2480 "fn": _fnUpdateInfo,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2481 "sName": "information"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2482 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2483
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2484 /* Add id */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2485 nInfo.id = oSettings.sTableId+'_info';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2486 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2487 oSettings.nTable.setAttribute( 'aria-describedby', oSettings.sTableId+'_info' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2488
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2489 return nInfo;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2490 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2491
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2492
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2493 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2494 * Update the information elements in the display
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2495 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2496 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2497 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2498 function _fnUpdateInfo ( oSettings )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2499 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2500 /* Show information about the table */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2501 if ( !oSettings.oFeatures.bInfo || oSettings.aanFeatures.i.length === 0 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2502 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2503 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2504 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2505
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2506 var
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2507 oLang = oSettings.oLanguage,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2508 iStart = oSettings._iDisplayStart+1,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2509 iEnd = oSettings.fnDisplayEnd(),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2510 iMax = oSettings.fnRecordsTotal(),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2511 iTotal = oSettings.fnRecordsDisplay(),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2512 sOut;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2513
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2514 if ( iTotal === 0 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2515 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2516 /* Empty record set */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2517 sOut = oLang.sInfoEmpty;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2518 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2519 else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2520 /* Normal record set */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2521 sOut = oLang.sInfo;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2522 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2523
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2524 if ( iTotal != iMax )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2525 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2526 /* Record set after filtering */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2527 sOut += ' ' + oLang.sInfoFiltered;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2528 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2529
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2530 // Convert the macros
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2531 sOut += oLang.sInfoPostFix;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2532 sOut = _fnInfoMacros( oSettings, sOut );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2533
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2534 if ( oLang.fnInfoCallback !== null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2535 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2536 sOut = oLang.fnInfoCallback.call( oSettings.oInstance,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2537 oSettings, iStart, iEnd, iMax, iTotal, sOut );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2538 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2539
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2540 var n = oSettings.aanFeatures.i;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2541 for ( var i=0, iLen=n.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2542 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2543 $(n[i]).html( sOut );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2544 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2545 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2546
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2547
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2548 function _fnInfoMacros ( oSettings, str )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2549 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2550 var
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2551 iStart = oSettings._iDisplayStart+1,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2552 sStart = oSettings.fnFormatNumber( iStart ),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2553 iEnd = oSettings.fnDisplayEnd(),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2554 sEnd = oSettings.fnFormatNumber( iEnd ),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2555 iTotal = oSettings.fnRecordsDisplay(),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2556 sTotal = oSettings.fnFormatNumber( iTotal ),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2557 iMax = oSettings.fnRecordsTotal(),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2558 sMax = oSettings.fnFormatNumber( iMax );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2559
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2560 // When infinite scrolling, we are always starting at 1. _iDisplayStart is used only
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2561 // internally
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2562 if ( oSettings.oScroll.bInfinite )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2563 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2564 sStart = oSettings.fnFormatNumber( 1 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2565 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2566
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2567 return str.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2568 replace(/_START_/g, sStart).
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2569 replace(/_END_/g, sEnd).
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2570 replace(/_TOTAL_/g, sTotal).
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2571 replace(/_MAX_/g, sMax);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2572 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2573
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2574
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2575
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2576 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2577 * Draw the table for the first time, adding all required features
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2578 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2579 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2580 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2581 function _fnInitialise ( oSettings )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2582 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2583 var i, iLen, iAjaxStart=oSettings.iInitDisplayStart;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2584
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2585 /* Ensure that the table data is fully initialised */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2586 if ( oSettings.bInitialised === false )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2587 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2588 setTimeout( function(){ _fnInitialise( oSettings ); }, 200 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2589 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2590 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2591
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2592 /* Show the display HTML options */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2593 _fnAddOptionsHtml( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2594
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2595 /* Build and draw the header / footer for the table */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2596 _fnBuildHead( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2597 _fnDrawHead( oSettings, oSettings.aoHeader );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2598 if ( oSettings.nTFoot )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2599 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2600 _fnDrawHead( oSettings, oSettings.aoFooter );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2601 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2602
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2603 /* Okay to show that something is going on now */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2604 _fnProcessingDisplay( oSettings, true );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2605
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2606 /* Calculate sizes for columns */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2607 if ( oSettings.oFeatures.bAutoWidth )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2608 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2609 _fnCalculateColumnWidths( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2610 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2611
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2612 for ( i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2613 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2614 if ( oSettings.aoColumns[i].sWidth !== null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2615 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2616 oSettings.aoColumns[i].nTh.style.width = _fnStringToCss( oSettings.aoColumns[i].sWidth );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2617 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2618 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2619
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2620 /* If there is default sorting required - let's do it. The sort function will do the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2621 * drawing for us. Otherwise we draw the table regardless of the Ajax source - this allows
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2622 * the table to look initialised for Ajax sourcing data (show 'loading' message possibly)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2623 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2624 if ( oSettings.oFeatures.bSort )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2625 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2626 _fnSort( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2627 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2628 else if ( oSettings.oFeatures.bFilter )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2629 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2630 _fnFilterComplete( oSettings, oSettings.oPreviousSearch );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2631 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2632 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2633 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2634 oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2635 _fnCalculateEnd( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2636 _fnDraw( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2637 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2638
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2639 /* if there is an ajax source load the data */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2640 if ( oSettings.sAjaxSource !== null && !oSettings.oFeatures.bServerSide )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2641 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2642 var aoData = [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2643 _fnServerParams( oSettings, aoData );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2644 oSettings.fnServerData.call( oSettings.oInstance, oSettings.sAjaxSource, aoData, function(json) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2645 var aData = (oSettings.sAjaxDataProp !== "") ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2646 _fnGetObjectDataFn( oSettings.sAjaxDataProp )(json) : json;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2647
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2648 /* Got the data - add it to the table */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2649 for ( i=0 ; i<aData.length ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2650 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2651 _fnAddData( oSettings, aData[i] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2652 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2653
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2654 /* Reset the init display for cookie saving. We've already done a filter, and
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2655 * therefore cleared it before. So we need to make it appear 'fresh'
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2656 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2657 oSettings.iInitDisplayStart = iAjaxStart;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2658
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2659 if ( oSettings.oFeatures.bSort )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2660 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2661 _fnSort( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2662 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2663 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2664 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2665 oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2666 _fnCalculateEnd( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2667 _fnDraw( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2668 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2669
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2670 _fnProcessingDisplay( oSettings, false );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2671 _fnInitComplete( oSettings, json );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2672 }, oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2673 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2674 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2675
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2676 /* Server-side processing initialisation complete is done at the end of _fnDraw */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2677 if ( !oSettings.oFeatures.bServerSide )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2678 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2679 _fnProcessingDisplay( oSettings, false );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2680 _fnInitComplete( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2681 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2682 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2683
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2684
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2685 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2686 * Draw the table for the first time, adding all required features
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2687 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2688 * @param {object} [json] JSON from the server that completed the table, if using Ajax source
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2689 * with client-side processing (optional)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2690 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2691 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2692 function _fnInitComplete ( oSettings, json )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2693 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2694 oSettings._bInitComplete = true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2695 _fnCallbackFire( oSettings, 'aoInitComplete', 'init', [oSettings, json] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2696 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2697
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2698
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2699 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2700 * Language compatibility - when certain options are given, and others aren't, we
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2701 * need to duplicate the values over, in order to provide backwards compatibility
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2702 * with older language files.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2703 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2704 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2705 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2706 function _fnLanguageCompat( oLanguage )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2707 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2708 var oDefaults = DataTable.defaults.oLanguage;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2709
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2710 /* Backwards compatibility - if there is no sEmptyTable given, then use the same as
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2711 * sZeroRecords - assuming that is given.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2712 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2713 if ( !oLanguage.sEmptyTable && oLanguage.sZeroRecords &&
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2714 oDefaults.sEmptyTable === "No data available in table" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2715 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2716 _fnMap( oLanguage, oLanguage, 'sZeroRecords', 'sEmptyTable' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2717 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2718
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2719 /* Likewise with loading records */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2720 if ( !oLanguage.sLoadingRecords && oLanguage.sZeroRecords &&
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2721 oDefaults.sLoadingRecords === "Loading..." )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2722 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2723 _fnMap( oLanguage, oLanguage, 'sZeroRecords', 'sLoadingRecords' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2724 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2725 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2726
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2727
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2728
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2729 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2730 * Generate the node required for user display length changing
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2731 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2732 * @returns {node} Display length feature node
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2733 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2734 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2735 function _fnFeatureHtmlLength ( oSettings )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2736 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2737 if ( oSettings.oScroll.bInfinite )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2738 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2739 return null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2740 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2741
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2742 /* This can be overruled by not using the _MENU_ var/macro in the language variable */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2743 var sName = 'name="'+oSettings.sTableId+'_length"';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2744 var sStdMenu = '<select size="1" '+sName+'>';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2745 var i, iLen;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2746 var aLengthMenu = oSettings.aLengthMenu;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2747
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2748 if ( aLengthMenu.length == 2 && typeof aLengthMenu[0] === 'object' &&
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2749 typeof aLengthMenu[1] === 'object' )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2750 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2751 for ( i=0, iLen=aLengthMenu[0].length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2752 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2753 sStdMenu += '<option value="'+aLengthMenu[0][i]+'">'+aLengthMenu[1][i]+'</option>';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2754 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2755 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2756 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2757 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2758 for ( i=0, iLen=aLengthMenu.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2759 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2760 sStdMenu += '<option value="'+aLengthMenu[i]+'">'+aLengthMenu[i]+'</option>';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2761 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2762 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2763 sStdMenu += '</select>';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2764
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2765 var nLength = document.createElement( 'div' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2766 if ( !oSettings.aanFeatures.l )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2767 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2768 nLength.id = oSettings.sTableId+'_length';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2769 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2770 nLength.className = oSettings.oClasses.sLength;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2771 nLength.innerHTML = '<label>'+oSettings.oLanguage.sLengthMenu.replace( '_MENU_', sStdMenu )+'</label>';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2772
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2773 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2774 * Set the length to the current display length - thanks to Andrea Pavlovic for this fix,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2775 * and Stefan Skopnik for fixing the fix!
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2776 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2777 $('select option[value="'+oSettings._iDisplayLength+'"]', nLength).attr("selected", true);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2778
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2779 $('select', nLength).bind( 'change.DT', function(e) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2780 var iVal = $(this).val();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2781
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2782 /* Update all other length options for the new display */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2783 var n = oSettings.aanFeatures.l;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2784 for ( i=0, iLen=n.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2785 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2786 if ( n[i] != this.parentNode )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2787 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2788 $('select', n[i]).val( iVal );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2789 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2790 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2791
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2792 /* Redraw the table */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2793 oSettings._iDisplayLength = parseInt(iVal, 10);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2794 _fnCalculateEnd( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2795
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2796 /* If we have space to show extra rows (backing up from the end point - then do so */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2797 if ( oSettings.fnDisplayEnd() == oSettings.fnRecordsDisplay() )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2798 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2799 oSettings._iDisplayStart = oSettings.fnDisplayEnd() - oSettings._iDisplayLength;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2800 if ( oSettings._iDisplayStart < 0 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2801 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2802 oSettings._iDisplayStart = 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2803 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2804 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2805
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2806 if ( oSettings._iDisplayLength == -1 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2807 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2808 oSettings._iDisplayStart = 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2809 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2810
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2811 _fnDraw( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2812 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2813
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2814
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2815 $('select', nLength).attr('aria-controls', oSettings.sTableId);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2816
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2817 return nLength;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2818 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2819
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2820
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2821 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2822 * Recalculate the end point based on the start point
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2823 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2824 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2825 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2826 function _fnCalculateEnd( oSettings )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2827 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2828 if ( oSettings.oFeatures.bPaginate === false )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2829 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2830 oSettings._iDisplayEnd = oSettings.aiDisplay.length;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2831 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2832 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2833 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2834 /* Set the end point of the display - based on how many elements there are
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2835 * still to display
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2836 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2837 if ( oSettings._iDisplayStart + oSettings._iDisplayLength > oSettings.aiDisplay.length ||
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2838 oSettings._iDisplayLength == -1 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2839 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2840 oSettings._iDisplayEnd = oSettings.aiDisplay.length;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2841 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2842 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2843 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2844 oSettings._iDisplayEnd = oSettings._iDisplayStart + oSettings._iDisplayLength;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2845 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2846 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2847 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2848
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2849
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2850
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2851 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2852 * Note that most of the paging logic is done in
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2853 * DataTable.ext.oPagination
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2854 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2855
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2856 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2857 * Generate the node required for default pagination
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2858 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2859 * @returns {node} Pagination feature node
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2860 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2861 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2862 function _fnFeatureHtmlPaginate ( oSettings )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2863 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2864 if ( oSettings.oScroll.bInfinite )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2865 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2866 return null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2867 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2868
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2869 var nPaginate = document.createElement( 'div' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2870 nPaginate.className = oSettings.oClasses.sPaging+oSettings.sPaginationType;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2871
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2872 DataTable.ext.oPagination[ oSettings.sPaginationType ].fnInit( oSettings, nPaginate,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2873 function( oSettings ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2874 _fnCalculateEnd( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2875 _fnDraw( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2876 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2877 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2878
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2879 /* Add a draw callback for the pagination on first instance, to update the paging display */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2880 if ( !oSettings.aanFeatures.p )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2881 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2882 oSettings.aoDrawCallback.push( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2883 "fn": function( oSettings ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2884 DataTable.ext.oPagination[ oSettings.sPaginationType ].fnUpdate( oSettings, function( oSettings ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2885 _fnCalculateEnd( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2886 _fnDraw( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2887 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2888 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2889 "sName": "pagination"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2890 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2891 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2892 return nPaginate;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2893 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2894
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2895
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2896 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2897 * Alter the display settings to change the page
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2898 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2899 * @param {string|int} mAction Paging action to take: "first", "previous", "next" or "last"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2900 * or page number to jump to (integer)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2901 * @returns {bool} true page has changed, false - no change (no effect) eg 'first' on page 1
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2902 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2903 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2904 function _fnPageChange ( oSettings, mAction )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2905 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2906 var iOldStart = oSettings._iDisplayStart;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2907
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2908 if ( typeof mAction === "number" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2909 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2910 oSettings._iDisplayStart = mAction * oSettings._iDisplayLength;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2911 if ( oSettings._iDisplayStart > oSettings.fnRecordsDisplay() )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2912 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2913 oSettings._iDisplayStart = 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2914 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2915 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2916 else if ( mAction == "first" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2917 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2918 oSettings._iDisplayStart = 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2919 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2920 else if ( mAction == "previous" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2921 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2922 oSettings._iDisplayStart = oSettings._iDisplayLength>=0 ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2923 oSettings._iDisplayStart - oSettings._iDisplayLength :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2924 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2925
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2926 /* Correct for under-run */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2927 if ( oSettings._iDisplayStart < 0 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2928 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2929 oSettings._iDisplayStart = 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2930 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2931 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2932 else if ( mAction == "next" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2933 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2934 if ( oSettings._iDisplayLength >= 0 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2935 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2936 /* Make sure we are not over running the display array */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2937 if ( oSettings._iDisplayStart + oSettings._iDisplayLength < oSettings.fnRecordsDisplay() )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2938 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2939 oSettings._iDisplayStart += oSettings._iDisplayLength;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2940 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2941 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2942 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2943 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2944 oSettings._iDisplayStart = 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2945 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2946 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2947 else if ( mAction == "last" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2948 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2949 if ( oSettings._iDisplayLength >= 0 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2950 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2951 var iPages = parseInt( (oSettings.fnRecordsDisplay()-1) / oSettings._iDisplayLength, 10 ) + 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2952 oSettings._iDisplayStart = (iPages-1) * oSettings._iDisplayLength;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2953 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2954 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2955 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2956 oSettings._iDisplayStart = 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2957 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2958 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2959 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2960 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2961 _fnLog( oSettings, 0, "Unknown paging action: "+mAction );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2962 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2963 $(oSettings.oInstance).trigger('page', oSettings);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2964
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2965 return iOldStart != oSettings._iDisplayStart;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2966 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2967
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2968
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2969
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2970 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2971 * Generate the node required for the processing node
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2972 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2973 * @returns {node} Processing element
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2974 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2975 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2976 function _fnFeatureHtmlProcessing ( oSettings )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2977 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2978 var nProcessing = document.createElement( 'div' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2979
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2980 if ( !oSettings.aanFeatures.r )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2981 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2982 nProcessing.id = oSettings.sTableId+'_processing';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2983 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2984 nProcessing.innerHTML = oSettings.oLanguage.sProcessing;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2985 nProcessing.className = oSettings.oClasses.sProcessing;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2986 oSettings.nTable.parentNode.insertBefore( nProcessing, oSettings.nTable );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2987
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2988 return nProcessing;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2989 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2990
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2991
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2992 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2993 * Display or hide the processing indicator
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2994 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2995 * @param {bool} bShow Show the processing indicator (true) or not (false)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2996 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2997 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2998 function _fnProcessingDisplay ( oSettings, bShow )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2999 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3000 if ( oSettings.oFeatures.bProcessing )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3001 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3002 var an = oSettings.aanFeatures.r;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3003 for ( var i=0, iLen=an.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3004 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3005 an[i].style.visibility = bShow ? "visible" : "hidden";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3006 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3007 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3008
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3009 $(oSettings.oInstance).trigger('processing', [oSettings, bShow]);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3010 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3011
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3012 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3013 * Add any control elements for the table - specifically scrolling
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3014 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3015 * @returns {node} Node to add to the DOM
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3016 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3017 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3018 function _fnFeatureHtmlTable ( oSettings )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3019 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3020 /* Check if scrolling is enabled or not - if not then leave the DOM unaltered */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3021 if ( oSettings.oScroll.sX === "" && oSettings.oScroll.sY === "" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3022 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3023 return oSettings.nTable;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3024 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3025
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3026 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3027 * The HTML structure that we want to generate in this function is:
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3028 * div - nScroller
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3029 * div - nScrollHead
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3030 * div - nScrollHeadInner
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3031 * table - nScrollHeadTable
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3032 * thead - nThead
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3033 * div - nScrollBody
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3034 * table - oSettings.nTable
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3035 * thead - nTheadSize
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3036 * tbody - nTbody
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3037 * div - nScrollFoot
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3038 * div - nScrollFootInner
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3039 * table - nScrollFootTable
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3040 * tfoot - nTfoot
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3041 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3042 var
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3043 nScroller = document.createElement('div'),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3044 nScrollHead = document.createElement('div'),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3045 nScrollHeadInner = document.createElement('div'),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3046 nScrollBody = document.createElement('div'),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3047 nScrollFoot = document.createElement('div'),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3048 nScrollFootInner = document.createElement('div'),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3049 nScrollHeadTable = oSettings.nTable.cloneNode(false),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3050 nScrollFootTable = oSettings.nTable.cloneNode(false),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3051 nThead = oSettings.nTable.getElementsByTagName('thead')[0],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3052 nTfoot = oSettings.nTable.getElementsByTagName('tfoot').length === 0 ? null :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3053 oSettings.nTable.getElementsByTagName('tfoot')[0],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3054 oClasses = oSettings.oClasses;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3055
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3056 nScrollHead.appendChild( nScrollHeadInner );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3057 nScrollFoot.appendChild( nScrollFootInner );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3058 nScrollBody.appendChild( oSettings.nTable );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3059 nScroller.appendChild( nScrollHead );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3060 nScroller.appendChild( nScrollBody );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3061 nScrollHeadInner.appendChild( nScrollHeadTable );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3062 nScrollHeadTable.appendChild( nThead );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3063 if ( nTfoot !== null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3064 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3065 nScroller.appendChild( nScrollFoot );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3066 nScrollFootInner.appendChild( nScrollFootTable );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3067 nScrollFootTable.appendChild( nTfoot );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3068 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3069
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3070 nScroller.className = oClasses.sScrollWrapper;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3071 nScrollHead.className = oClasses.sScrollHead;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3072 nScrollHeadInner.className = oClasses.sScrollHeadInner;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3073 nScrollBody.className = oClasses.sScrollBody;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3074 nScrollFoot.className = oClasses.sScrollFoot;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3075 nScrollFootInner.className = oClasses.sScrollFootInner;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3076
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3077 if ( oSettings.oScroll.bAutoCss )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3078 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3079 nScrollHead.style.overflow = "hidden";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3080 nScrollHead.style.position = "relative";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3081 nScrollFoot.style.overflow = "hidden";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3082 nScrollBody.style.overflow = "auto";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3083 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3084
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3085 nScrollHead.style.border = "0";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3086 nScrollHead.style.width = "100%";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3087 nScrollFoot.style.border = "0";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3088 nScrollHeadInner.style.width = oSettings.oScroll.sXInner !== "" ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3089 oSettings.oScroll.sXInner : "100%"; /* will be overwritten */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3090
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3091 /* Modify attributes to respect the clones */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3092 nScrollHeadTable.removeAttribute('id');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3093 nScrollHeadTable.style.marginLeft = "0";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3094 oSettings.nTable.style.marginLeft = "0";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3095 if ( nTfoot !== null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3096 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3097 nScrollFootTable.removeAttribute('id');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3098 nScrollFootTable.style.marginLeft = "0";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3099 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3100
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3101 /* Move caption elements from the body to the header, footer or leave where it is
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3102 * depending on the configuration. Note that the DTD says there can be only one caption */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3103 var nCaption = $(oSettings.nTable).children('caption');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3104 if ( nCaption.length > 0 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3105 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3106 nCaption = nCaption[0];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3107 if ( nCaption._captionSide === "top" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3108 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3109 nScrollHeadTable.appendChild( nCaption );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3110 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3111 else if ( nCaption._captionSide === "bottom" && nTfoot )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3112 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3113 nScrollFootTable.appendChild( nCaption );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3114 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3115 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3116
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3117 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3118 * Sizing
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3119 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3120 /* When x-scrolling add the width and a scroller to move the header with the body */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3121 if ( oSettings.oScroll.sX !== "" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3122 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3123 nScrollHead.style.width = _fnStringToCss( oSettings.oScroll.sX );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3124 nScrollBody.style.width = _fnStringToCss( oSettings.oScroll.sX );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3125
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3126 if ( nTfoot !== null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3127 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3128 nScrollFoot.style.width = _fnStringToCss( oSettings.oScroll.sX );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3129 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3130
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3131 /* When the body is scrolled, then we also want to scroll the headers */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3132 $(nScrollBody).scroll( function (e) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3133 nScrollHead.scrollLeft = this.scrollLeft;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3134
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3135 if ( nTfoot !== null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3136 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3137 nScrollFoot.scrollLeft = this.scrollLeft;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3138 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3139 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3140 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3141
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3142 /* When yscrolling, add the height */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3143 if ( oSettings.oScroll.sY !== "" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3144 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3145 nScrollBody.style.height = _fnStringToCss( oSettings.oScroll.sY );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3146 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3147
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3148 /* Redraw - align columns across the tables */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3149 oSettings.aoDrawCallback.push( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3150 "fn": _fnScrollDraw,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3151 "sName": "scrolling"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3152 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3153
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3154 /* Infinite scrolling event handlers */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3155 if ( oSettings.oScroll.bInfinite )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3156 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3157 $(nScrollBody).scroll( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3158 /* Use a blocker to stop scrolling from loading more data while other data is still loading */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3159 if ( !oSettings.bDrawing && $(this).scrollTop() !== 0 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3160 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3161 /* Check if we should load the next data set */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3162 if ( $(this).scrollTop() + $(this).height() >
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3163 $(oSettings.nTable).height() - oSettings.oScroll.iLoadGap )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3164 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3165 /* Only do the redraw if we have to - we might be at the end of the data */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3166 if ( oSettings.fnDisplayEnd() < oSettings.fnRecordsDisplay() )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3167 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3168 _fnPageChange( oSettings, 'next' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3169 _fnCalculateEnd( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3170 _fnDraw( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3171 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3172 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3173 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3174 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3175 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3176
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3177 oSettings.nScrollHead = nScrollHead;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3178 oSettings.nScrollFoot = nScrollFoot;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3179
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3180 return nScroller;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3181 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3182
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3183
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3184 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3185 * Update the various tables for resizing. It's a bit of a pig this function, but
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3186 * basically the idea to:
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3187 * 1. Re-create the table inside the scrolling div
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3188 * 2. Take live measurements from the DOM
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3189 * 3. Apply the measurements
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3190 * 4. Clean up
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3191 * @param {object} o dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3192 * @returns {node} Node to add to the DOM
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3193 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3194 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3195 function _fnScrollDraw ( o )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3196 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3197 var
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3198 nScrollHeadInner = o.nScrollHead.getElementsByTagName('div')[0],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3199 nScrollHeadTable = nScrollHeadInner.getElementsByTagName('table')[0],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3200 nScrollBody = o.nTable.parentNode,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3201 i, iLen, j, jLen, anHeadToSize, anHeadSizers, anFootSizers, anFootToSize, oStyle, iVis,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3202 nTheadSize, nTfootSize,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3203 iWidth, aApplied=[], aAppliedFooter=[], iSanityWidth,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3204 nScrollFootInner = (o.nTFoot !== null) ? o.nScrollFoot.getElementsByTagName('div')[0] : null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3205 nScrollFootTable = (o.nTFoot !== null) ? nScrollFootInner.getElementsByTagName('table')[0] : null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3206 ie67 = o.oBrowser.bScrollOversize,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3207 zeroOut = function(nSizer) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3208 oStyle = nSizer.style;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3209 oStyle.paddingTop = "0";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3210 oStyle.paddingBottom = "0";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3211 oStyle.borderTopWidth = "0";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3212 oStyle.borderBottomWidth = "0";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3213 oStyle.height = 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3214 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3215
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3216 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3217 * 1. Re-create the table inside the scrolling div
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3218 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3219
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3220 /* Remove the old minimised thead and tfoot elements in the inner table */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3221 $(o.nTable).children('thead, tfoot').remove();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3222
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3223 /* Clone the current header and footer elements and then place it into the inner table */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3224 nTheadSize = $(o.nTHead).clone()[0];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3225 o.nTable.insertBefore( nTheadSize, o.nTable.childNodes[0] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3226 anHeadToSize = o.nTHead.getElementsByTagName('tr');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3227 anHeadSizers = nTheadSize.getElementsByTagName('tr');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3228
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3229 if ( o.nTFoot !== null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3230 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3231 nTfootSize = $(o.nTFoot).clone()[0];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3232 o.nTable.insertBefore( nTfootSize, o.nTable.childNodes[1] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3233 anFootToSize = o.nTFoot.getElementsByTagName('tr');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3234 anFootSizers = nTfootSize.getElementsByTagName('tr');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3235 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3236
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3237 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3238 * 2. Take live measurements from the DOM - do not alter the DOM itself!
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3239 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3240
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3241 /* Remove old sizing and apply the calculated column widths
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3242 * Get the unique column headers in the newly created (cloned) header. We want to apply the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3243 * calculated sizes to this header
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3244 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3245 if ( o.oScroll.sX === "" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3246 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3247 nScrollBody.style.width = '100%';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3248 nScrollHeadInner.parentNode.style.width = '100%';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3249 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3250
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3251 var nThs = _fnGetUniqueThs( o, nTheadSize );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3252 for ( i=0, iLen=nThs.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3253 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3254 iVis = _fnVisibleToColumnIndex( o, i );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3255 nThs[i].style.width = o.aoColumns[iVis].sWidth;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3256 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3257
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3258 if ( o.nTFoot !== null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3259 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3260 _fnApplyToChildren( function(n) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3261 n.style.width = "";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3262 }, anFootSizers );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3263 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3264
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3265 // If scroll collapse is enabled, when we put the headers back into the body for sizing, we
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3266 // will end up forcing the scrollbar to appear, making our measurements wrong for when we
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3267 // then hide it (end of this function), so add the header height to the body scroller.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3268 if ( o.oScroll.bCollapse && o.oScroll.sY !== "" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3269 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3270 nScrollBody.style.height = (nScrollBody.offsetHeight + o.nTHead.offsetHeight)+"px";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3271 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3272
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3273 /* Size the table as a whole */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3274 iSanityWidth = $(o.nTable).outerWidth();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3275 if ( o.oScroll.sX === "" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3276 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3277 /* No x scrolling */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3278 o.nTable.style.width = "100%";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3279
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3280 /* I know this is rubbish - but IE7 will make the width of the table when 100% include
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3281 * the scrollbar - which is shouldn't. When there is a scrollbar we need to take this
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3282 * into account.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3283 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3284 if ( ie67 && ($('tbody', nScrollBody).height() > nScrollBody.offsetHeight ||
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3285 $(nScrollBody).css('overflow-y') == "scroll") )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3286 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3287 o.nTable.style.width = _fnStringToCss( $(o.nTable).outerWidth() - o.oScroll.iBarWidth);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3288 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3289 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3290 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3291 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3292 if ( o.oScroll.sXInner !== "" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3293 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3294 /* x scroll inner has been given - use it */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3295 o.nTable.style.width = _fnStringToCss(o.oScroll.sXInner);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3296 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3297 else if ( iSanityWidth == $(nScrollBody).width() &&
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3298 $(nScrollBody).height() < $(o.nTable).height() )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3299 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3300 /* There is y-scrolling - try to take account of the y scroll bar */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3301 o.nTable.style.width = _fnStringToCss( iSanityWidth-o.oScroll.iBarWidth );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3302 if ( $(o.nTable).outerWidth() > iSanityWidth-o.oScroll.iBarWidth )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3303 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3304 /* Not possible to take account of it */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3305 o.nTable.style.width = _fnStringToCss( iSanityWidth );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3306 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3307 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3308 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3309 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3310 /* All else fails */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3311 o.nTable.style.width = _fnStringToCss( iSanityWidth );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3312 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3313 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3314
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3315 /* Recalculate the sanity width - now that we've applied the required width, before it was
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3316 * a temporary variable. This is required because the column width calculation is done
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3317 * before this table DOM is created.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3318 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3319 iSanityWidth = $(o.nTable).outerWidth();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3320
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3321 /* We want the hidden header to have zero height, so remove padding and borders. Then
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3322 * set the width based on the real headers
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3323 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3324
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3325 // Apply all styles in one pass. Invalidates layout only once because we don't read any
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3326 // DOM properties.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3327 _fnApplyToChildren( zeroOut, anHeadSizers );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3328
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3329 // Read all widths in next pass. Forces layout only once because we do not change
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3330 // any DOM properties.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3331 _fnApplyToChildren( function(nSizer) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3332 aApplied.push( _fnStringToCss( $(nSizer).width() ) );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3333 }, anHeadSizers );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3334
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3335 // Apply all widths in final pass. Invalidates layout only once because we do not
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3336 // read any DOM properties.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3337 _fnApplyToChildren( function(nToSize, i) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3338 nToSize.style.width = aApplied[i];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3339 }, anHeadToSize );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3340
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3341 $(anHeadSizers).height(0);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3342
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3343 /* Same again with the footer if we have one */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3344 if ( o.nTFoot !== null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3345 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3346 _fnApplyToChildren( zeroOut, anFootSizers );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3347
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3348 _fnApplyToChildren( function(nSizer) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3349 aAppliedFooter.push( _fnStringToCss( $(nSizer).width() ) );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3350 }, anFootSizers );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3351
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3352 _fnApplyToChildren( function(nToSize, i) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3353 nToSize.style.width = aAppliedFooter[i];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3354 }, anFootToSize );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3355
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3356 $(anFootSizers).height(0);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3357 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3358
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3359 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3360 * 3. Apply the measurements
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3361 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3362
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3363 /* "Hide" the header and footer that we used for the sizing. We want to also fix their width
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3364 * to what they currently are
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3365 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3366 _fnApplyToChildren( function(nSizer, i) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3367 nSizer.innerHTML = "";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3368 nSizer.style.width = aApplied[i];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3369 }, anHeadSizers );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3370
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3371 if ( o.nTFoot !== null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3372 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3373 _fnApplyToChildren( function(nSizer, i) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3374 nSizer.innerHTML = "";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3375 nSizer.style.width = aAppliedFooter[i];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3376 }, anFootSizers );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3377 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3378
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3379 /* Sanity check that the table is of a sensible width. If not then we are going to get
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3380 * misalignment - try to prevent this by not allowing the table to shrink below its min width
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3381 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3382 if ( $(o.nTable).outerWidth() < iSanityWidth )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3383 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3384 /* The min width depends upon if we have a vertical scrollbar visible or not */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3385 var iCorrection = ((nScrollBody.scrollHeight > nScrollBody.offsetHeight ||
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3386 $(nScrollBody).css('overflow-y') == "scroll")) ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3387 iSanityWidth+o.oScroll.iBarWidth : iSanityWidth;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3388
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3389 /* IE6/7 are a law unto themselves... */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3390 if ( ie67 && (nScrollBody.scrollHeight >
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3391 nScrollBody.offsetHeight || $(nScrollBody).css('overflow-y') == "scroll") )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3392 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3393 o.nTable.style.width = _fnStringToCss( iCorrection-o.oScroll.iBarWidth );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3394 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3395
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3396 /* Apply the calculated minimum width to the table wrappers */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3397 nScrollBody.style.width = _fnStringToCss( iCorrection );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3398 o.nScrollHead.style.width = _fnStringToCss( iCorrection );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3399
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3400 if ( o.nTFoot !== null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3401 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3402 o.nScrollFoot.style.width = _fnStringToCss( iCorrection );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3403 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3404
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3405 /* And give the user a warning that we've stopped the table getting too small */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3406 if ( o.oScroll.sX === "" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3407 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3408 _fnLog( o, 1, "The table cannot fit into the current element which will cause column"+
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3409 " misalignment. The table has been drawn at its minimum possible width." );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3410 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3411 else if ( o.oScroll.sXInner !== "" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3412 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3413 _fnLog( o, 1, "The table cannot fit into the current element which will cause column"+
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3414 " misalignment. Increase the sScrollXInner value or remove it to allow automatic"+
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3415 " calculation" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3416 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3417 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3418 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3419 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3420 nScrollBody.style.width = _fnStringToCss( '100%' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3421 o.nScrollHead.style.width = _fnStringToCss( '100%' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3422
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3423 if ( o.nTFoot !== null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3424 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3425 o.nScrollFoot.style.width = _fnStringToCss( '100%' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3426 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3427 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3428
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3429
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3430 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3431 * 4. Clean up
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3432 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3433 if ( o.oScroll.sY === "" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3434 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3435 /* IE7< puts a vertical scrollbar in place (when it shouldn't be) due to subtracting
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3436 * the scrollbar height from the visible display, rather than adding it on. We need to
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3437 * set the height in order to sort this. Don't want to do it in any other browsers.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3438 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3439 if ( ie67 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3440 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3441 nScrollBody.style.height = _fnStringToCss( o.nTable.offsetHeight+o.oScroll.iBarWidth );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3442 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3443 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3444
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3445 if ( o.oScroll.sY !== "" && o.oScroll.bCollapse )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3446 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3447 nScrollBody.style.height = _fnStringToCss( o.oScroll.sY );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3448
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3449 var iExtra = (o.oScroll.sX !== "" && o.nTable.offsetWidth > nScrollBody.offsetWidth) ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3450 o.oScroll.iBarWidth : 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3451 if ( o.nTable.offsetHeight < nScrollBody.offsetHeight )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3452 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3453 nScrollBody.style.height = _fnStringToCss( o.nTable.offsetHeight+iExtra );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3454 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3455 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3456
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3457 /* Finally set the width's of the header and footer tables */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3458 var iOuterWidth = $(o.nTable).outerWidth();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3459 nScrollHeadTable.style.width = _fnStringToCss( iOuterWidth );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3460 nScrollHeadInner.style.width = _fnStringToCss( iOuterWidth );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3461
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3462 // Figure out if there are scrollbar present - if so then we need a the header and footer to
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3463 // provide a bit more space to allow "overflow" scrolling (i.e. past the scrollbar)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3464 var bScrolling = $(o.nTable).height() > nScrollBody.clientHeight || $(nScrollBody).css('overflow-y') == "scroll";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3465 nScrollHeadInner.style.paddingRight = bScrolling ? o.oScroll.iBarWidth+"px" : "0px";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3466
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3467 if ( o.nTFoot !== null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3468 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3469 nScrollFootTable.style.width = _fnStringToCss( iOuterWidth );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3470 nScrollFootInner.style.width = _fnStringToCss( iOuterWidth );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3471 nScrollFootInner.style.paddingRight = bScrolling ? o.oScroll.iBarWidth+"px" : "0px";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3472 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3473
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3474 /* Adjust the position of the header in case we loose the y-scrollbar */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3475 $(nScrollBody).scroll();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3476
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3477 /* If sorting or filtering has occurred, jump the scrolling back to the top */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3478 if ( o.bSorted || o.bFiltered )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3479 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3480 nScrollBody.scrollTop = 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3481 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3482 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3483
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3484
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3485 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3486 * Apply a given function to the display child nodes of an element array (typically
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3487 * TD children of TR rows
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3488 * @param {function} fn Method to apply to the objects
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3489 * @param array {nodes} an1 List of elements to look through for display children
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3490 * @param array {nodes} an2 Another list (identical structure to the first) - optional
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3491 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3492 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3493 function _fnApplyToChildren( fn, an1, an2 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3494 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3495 var index=0, i=0, iLen=an1.length;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3496 var nNode1, nNode2;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3497
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3498 while ( i < iLen )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3499 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3500 nNode1 = an1[i].firstChild;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3501 nNode2 = an2 ? an2[i].firstChild : null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3502 while ( nNode1 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3503 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3504 if ( nNode1.nodeType === 1 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3505 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3506 if ( an2 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3507 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3508 fn( nNode1, nNode2, index );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3509 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3510 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3511 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3512 fn( nNode1, index );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3513 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3514 index++;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3515 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3516 nNode1 = nNode1.nextSibling;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3517 nNode2 = an2 ? nNode2.nextSibling : null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3518 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3519 i++;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3520 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3521 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3522
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3523 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3524 * Convert a CSS unit width to pixels (e.g. 2em)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3525 * @param {string} sWidth width to be converted
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3526 * @param {node} nParent parent to get the with for (required for relative widths) - optional
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3527 * @returns {int} iWidth width in pixels
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3528 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3529 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3530 function _fnConvertToWidth ( sWidth, nParent )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3531 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3532 if ( !sWidth || sWidth === null || sWidth === '' )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3533 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3534 return 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3535 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3536
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3537 if ( !nParent )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3538 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3539 nParent = document.body;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3540 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3541
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3542 var iWidth;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3543 var nTmp = document.createElement( "div" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3544 nTmp.style.width = _fnStringToCss( sWidth );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3545
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3546 nParent.appendChild( nTmp );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3547 iWidth = nTmp.offsetWidth;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3548 nParent.removeChild( nTmp );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3549
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3550 return ( iWidth );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3551 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3552
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3553
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3554 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3555 * Calculate the width of columns for the table
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3556 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3557 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3558 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3559 function _fnCalculateColumnWidths ( oSettings )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3560 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3561 var iTableWidth = oSettings.nTable.offsetWidth;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3562 var iUserInputs = 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3563 var iTmpWidth;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3564 var iVisibleColumns = 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3565 var iColums = oSettings.aoColumns.length;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3566 var i, iIndex, iCorrector, iWidth;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3567 var oHeaders = $('th', oSettings.nTHead);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3568 var widthAttr = oSettings.nTable.getAttribute('width');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3569 var nWrapper = oSettings.nTable.parentNode;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3570
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3571 /* Convert any user input sizes into pixel sizes */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3572 for ( i=0 ; i<iColums ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3573 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3574 if ( oSettings.aoColumns[i].bVisible )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3575 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3576 iVisibleColumns++;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3577
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3578 if ( oSettings.aoColumns[i].sWidth !== null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3579 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3580 iTmpWidth = _fnConvertToWidth( oSettings.aoColumns[i].sWidthOrig,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3581 nWrapper );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3582 if ( iTmpWidth !== null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3583 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3584 oSettings.aoColumns[i].sWidth = _fnStringToCss( iTmpWidth );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3585 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3586
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3587 iUserInputs++;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3588 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3589 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3590 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3591
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3592 /* If the number of columns in the DOM equals the number that we have to process in
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3593 * DataTables, then we can use the offsets that are created by the web-browser. No custom
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3594 * sizes can be set in order for this to happen, nor scrolling used
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3595 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3596 if ( iColums == oHeaders.length && iUserInputs === 0 && iVisibleColumns == iColums &&
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3597 oSettings.oScroll.sX === "" && oSettings.oScroll.sY === "" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3598 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3599 for ( i=0 ; i<oSettings.aoColumns.length ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3600 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3601 iTmpWidth = $(oHeaders[i]).width();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3602 if ( iTmpWidth !== null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3603 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3604 oSettings.aoColumns[i].sWidth = _fnStringToCss( iTmpWidth );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3605 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3606 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3607 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3608 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3609 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3610 /* Otherwise we are going to have to do some calculations to get the width of each column.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3611 * Construct a 1 row table with the widest node in the data, and any user defined widths,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3612 * then insert it into the DOM and allow the browser to do all the hard work of
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3613 * calculating table widths.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3614 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3615 var
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3616 nCalcTmp = oSettings.nTable.cloneNode( false ),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3617 nTheadClone = oSettings.nTHead.cloneNode(true),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3618 nBody = document.createElement( 'tbody' ),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3619 nTr = document.createElement( 'tr' ),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3620 nDivSizing;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3621
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3622 nCalcTmp.removeAttribute( "id" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3623 nCalcTmp.appendChild( nTheadClone );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3624 if ( oSettings.nTFoot !== null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3625 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3626 nCalcTmp.appendChild( oSettings.nTFoot.cloneNode(true) );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3627 _fnApplyToChildren( function(n) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3628 n.style.width = "";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3629 }, nCalcTmp.getElementsByTagName('tr') );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3630 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3631
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3632 nCalcTmp.appendChild( nBody );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3633 nBody.appendChild( nTr );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3634
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3635 /* Remove any sizing that was previously applied by the styles */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3636 var jqColSizing = $('thead th', nCalcTmp);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3637 if ( jqColSizing.length === 0 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3638 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3639 jqColSizing = $('tbody tr:eq(0)>td', nCalcTmp);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3640 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3641
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3642 /* Apply custom sizing to the cloned header */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3643 var nThs = _fnGetUniqueThs( oSettings, nTheadClone );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3644 iCorrector = 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3645 for ( i=0 ; i<iColums ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3646 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3647 var oColumn = oSettings.aoColumns[i];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3648 if ( oColumn.bVisible && oColumn.sWidthOrig !== null && oColumn.sWidthOrig !== "" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3649 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3650 nThs[i-iCorrector].style.width = _fnStringToCss( oColumn.sWidthOrig );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3651 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3652 else if ( oColumn.bVisible )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3653 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3654 nThs[i-iCorrector].style.width = "";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3655 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3656 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3657 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3658 iCorrector++;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3659 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3660 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3661
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3662 /* Find the biggest td for each column and put it into the table */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3663 for ( i=0 ; i<iColums ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3664 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3665 if ( oSettings.aoColumns[i].bVisible )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3666 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3667 var nTd = _fnGetWidestNode( oSettings, i );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3668 if ( nTd !== null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3669 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3670 nTd = nTd.cloneNode(true);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3671 if ( oSettings.aoColumns[i].sContentPadding !== "" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3672 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3673 nTd.innerHTML += oSettings.aoColumns[i].sContentPadding;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3674 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3675 nTr.appendChild( nTd );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3676 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3677 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3678 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3679
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3680 /* Build the table and 'display' it */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3681 nWrapper.appendChild( nCalcTmp );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3682
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3683 /* When scrolling (X or Y) we want to set the width of the table as appropriate. However,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3684 * when not scrolling leave the table width as it is. This results in slightly different,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3685 * but I think correct behaviour
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3686 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3687 if ( oSettings.oScroll.sX !== "" && oSettings.oScroll.sXInner !== "" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3688 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3689 nCalcTmp.style.width = _fnStringToCss(oSettings.oScroll.sXInner);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3690 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3691 else if ( oSettings.oScroll.sX !== "" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3692 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3693 nCalcTmp.style.width = "";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3694 if ( $(nCalcTmp).width() < nWrapper.offsetWidth )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3695 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3696 nCalcTmp.style.width = _fnStringToCss( nWrapper.offsetWidth );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3697 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3698 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3699 else if ( oSettings.oScroll.sY !== "" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3700 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3701 nCalcTmp.style.width = _fnStringToCss( nWrapper.offsetWidth );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3702 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3703 else if ( widthAttr )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3704 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3705 nCalcTmp.style.width = _fnStringToCss( widthAttr );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3706 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3707 nCalcTmp.style.visibility = "hidden";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3708
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3709 /* Scrolling considerations */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3710 _fnScrollingWidthAdjust( oSettings, nCalcTmp );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3711
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3712 /* Read the width's calculated by the browser and store them for use by the caller. We
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3713 * first of all try to use the elements in the body, but it is possible that there are
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3714 * no elements there, under which circumstances we use the header elements
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3715 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3716 var oNodes = $("tbody tr:eq(0)", nCalcTmp).children();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3717 if ( oNodes.length === 0 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3718 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3719 oNodes = _fnGetUniqueThs( oSettings, $('thead', nCalcTmp)[0] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3720 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3721
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3722 /* Browsers need a bit of a hand when a width is assigned to any columns when
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3723 * x-scrolling as they tend to collapse the table to the min-width, even if
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3724 * we sent the column widths. So we need to keep track of what the table width
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3725 * should be by summing the user given values, and the automatic values
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3726 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3727 if ( oSettings.oScroll.sX !== "" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3728 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3729 var iTotal = 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3730 iCorrector = 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3731 for ( i=0 ; i<oSettings.aoColumns.length ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3732 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3733 if ( oSettings.aoColumns[i].bVisible )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3734 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3735 if ( oSettings.aoColumns[i].sWidthOrig === null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3736 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3737 iTotal += $(oNodes[iCorrector]).outerWidth();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3738 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3739 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3740 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3741 iTotal += parseInt(oSettings.aoColumns[i].sWidth.replace('px',''), 10) +
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3742 ($(oNodes[iCorrector]).outerWidth() - $(oNodes[iCorrector]).width());
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3743 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3744 iCorrector++;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3745 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3746 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3747
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3748 nCalcTmp.style.width = _fnStringToCss( iTotal );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3749 oSettings.nTable.style.width = _fnStringToCss( iTotal );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3750 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3751
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3752 iCorrector = 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3753 for ( i=0 ; i<oSettings.aoColumns.length ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3754 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3755 if ( oSettings.aoColumns[i].bVisible )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3756 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3757 iWidth = $(oNodes[iCorrector]).width();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3758 if ( iWidth !== null && iWidth > 0 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3759 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3760 oSettings.aoColumns[i].sWidth = _fnStringToCss( iWidth );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3761 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3762 iCorrector++;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3763 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3764 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3765
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3766 var cssWidth = $(nCalcTmp).css('width');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3767 oSettings.nTable.style.width = (cssWidth.indexOf('%') !== -1) ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3768 cssWidth : _fnStringToCss( $(nCalcTmp).outerWidth() );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3769 nCalcTmp.parentNode.removeChild( nCalcTmp );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3770 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3771
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3772 if ( widthAttr )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3773 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3774 oSettings.nTable.style.width = _fnStringToCss( widthAttr );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3775 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3776 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3777
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3778
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3779 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3780 * Adjust a table's width to take account of scrolling
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3781 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3782 * @param {node} n table node
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3783 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3784 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3785 function _fnScrollingWidthAdjust ( oSettings, n )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3786 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3787 if ( oSettings.oScroll.sX === "" && oSettings.oScroll.sY !== "" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3788 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3789 /* When y-scrolling only, we want to remove the width of the scroll bar so the table
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3790 * + scroll bar will fit into the area avaialble.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3791 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3792 var iOrigWidth = $(n).width();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3793 n.style.width = _fnStringToCss( $(n).outerWidth()-oSettings.oScroll.iBarWidth );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3794 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3795 else if ( oSettings.oScroll.sX !== "" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3796 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3797 /* When x-scrolling both ways, fix the table at it's current size, without adjusting */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3798 n.style.width = _fnStringToCss( $(n).outerWidth() );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3799 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3800 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3801
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3802
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3803 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3804 * Get the widest node
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3805 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3806 * @param {int} iCol column of interest
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3807 * @returns {node} widest table node
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3808 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3809 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3810 function _fnGetWidestNode( oSettings, iCol )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3811 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3812 var iMaxIndex = _fnGetMaxLenString( oSettings, iCol );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3813 if ( iMaxIndex < 0 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3814 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3815 return null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3816 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3817
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3818 if ( oSettings.aoData[iMaxIndex].nTr === null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3819 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3820 var n = document.createElement('td');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3821 n.innerHTML = _fnGetCellData( oSettings, iMaxIndex, iCol, '' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3822 return n;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3823 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3824 return _fnGetTdNodes(oSettings, iMaxIndex)[iCol];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3825 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3826
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3827
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3828 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3829 * Get the maximum strlen for each data column
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3830 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3831 * @param {int} iCol column of interest
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3832 * @returns {string} max string length for each column
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3833 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3834 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3835 function _fnGetMaxLenString( oSettings, iCol )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3836 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3837 var iMax = -1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3838 var iMaxIndex = -1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3839
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3840 for ( var i=0 ; i<oSettings.aoData.length ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3841 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3842 var s = _fnGetCellData( oSettings, i, iCol, 'display' )+"";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3843 s = s.replace( /<.*?>/g, "" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3844 if ( s.length > iMax )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3845 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3846 iMax = s.length;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3847 iMaxIndex = i;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3848 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3849 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3850
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3851 return iMaxIndex;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3852 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3853
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3854
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3855 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3856 * Append a CSS unit (only if required) to a string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3857 * @param {array} aArray1 first array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3858 * @param {array} aArray2 second array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3859 * @returns {int} 0 if match, 1 if length is different, 2 if no match
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3860 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3861 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3862 function _fnStringToCss( s )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3863 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3864 if ( s === null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3865 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3866 return "0px";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3867 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3868
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3869 if ( typeof s == 'number' )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3870 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3871 if ( s < 0 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3872 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3873 return "0px";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3874 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3875 return s+"px";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3876 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3877
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3878 /* Check if the last character is not 0-9 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3879 var c = s.charCodeAt( s.length-1 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3880 if (c < 0x30 || c > 0x39)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3881 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3882 return s;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3883 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3884 return s+"px";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3885 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3886
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3887
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3888 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3889 * Get the width of a scroll bar in this browser being used
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3890 * @returns {int} width in pixels
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3891 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3892 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3893 function _fnScrollBarWidth ()
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3894 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3895 var inner = document.createElement('p');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3896 var style = inner.style;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3897 style.width = "100%";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3898 style.height = "200px";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3899 style.padding = "0px";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3900
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3901 var outer = document.createElement('div');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3902 style = outer.style;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3903 style.position = "absolute";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3904 style.top = "0px";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3905 style.left = "0px";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3906 style.visibility = "hidden";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3907 style.width = "200px";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3908 style.height = "150px";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3909 style.padding = "0px";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3910 style.overflow = "hidden";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3911 outer.appendChild(inner);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3912
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3913 document.body.appendChild(outer);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3914 var w1 = inner.offsetWidth;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3915 outer.style.overflow = 'scroll';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3916 var w2 = inner.offsetWidth;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3917 if ( w1 == w2 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3918 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3919 w2 = outer.clientWidth;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3920 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3921
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3922 document.body.removeChild(outer);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3923 return (w1 - w2);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3924 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3925
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3926 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3927 * Change the order of the table
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3928 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3929 * @param {bool} bApplyClasses optional - should we apply classes or not
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3930 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3931 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3932 function _fnSort ( oSettings, bApplyClasses )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3933 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3934 var
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3935 i, iLen, j, jLen, k, kLen,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3936 sDataType, nTh,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3937 aaSort = [],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3938 aiOrig = [],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3939 oSort = DataTable.ext.oSort,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3940 aoData = oSettings.aoData,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3941 aoColumns = oSettings.aoColumns,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3942 oAria = oSettings.oLanguage.oAria;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3943
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3944 /* No sorting required if server-side or no sorting array */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3945 if ( !oSettings.oFeatures.bServerSide &&
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3946 (oSettings.aaSorting.length !== 0 || oSettings.aaSortingFixed !== null) )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3947 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3948 aaSort = ( oSettings.aaSortingFixed !== null ) ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3949 oSettings.aaSortingFixed.concat( oSettings.aaSorting ) :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3950 oSettings.aaSorting.slice();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3951
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3952 /* If there is a sorting data type, and a function belonging to it, then we need to
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3953 * get the data from the developer's function and apply it for this column
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3954 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3955 for ( i=0 ; i<aaSort.length ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3956 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3957 var iColumn = aaSort[i][0];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3958 var iVisColumn = _fnColumnIndexToVisible( oSettings, iColumn );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3959 sDataType = oSettings.aoColumns[ iColumn ].sSortDataType;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3960 if ( DataTable.ext.afnSortData[sDataType] )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3961 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3962 var aData = DataTable.ext.afnSortData[sDataType].call(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3963 oSettings.oInstance, oSettings, iColumn, iVisColumn
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3964 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3965 if ( aData.length === aoData.length )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3966 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3967 for ( j=0, jLen=aoData.length ; j<jLen ; j++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3968 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3969 _fnSetCellData( oSettings, j, iColumn, aData[j] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3970 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3971 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3972 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3973 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3974 _fnLog( oSettings, 0, "Returned data sort array (col "+iColumn+") is the wrong length" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3975 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3976 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3977 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3978
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3979 /* Create a value - key array of the current row positions such that we can use their
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3980 * current position during the sort, if values match, in order to perform stable sorting
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3981 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3982 for ( i=0, iLen=oSettings.aiDisplayMaster.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3983 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3984 aiOrig[ oSettings.aiDisplayMaster[i] ] = i;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3985 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3986
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3987 /* Build an internal data array which is specific to the sort, so we can get and prep
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3988 * the data to be sorted only once, rather than needing to do it every time the sorting
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3989 * function runs. This make the sorting function a very simple comparison
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3990 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3991 var iSortLen = aaSort.length;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3992 var fnSortFormat, aDataSort;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3993 for ( i=0, iLen=aoData.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3994 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3995 for ( j=0 ; j<iSortLen ; j++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3996 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3997 aDataSort = aoColumns[ aaSort[j][0] ].aDataSort;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3998
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3999 for ( k=0, kLen=aDataSort.length ; k<kLen ; k++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4000 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4001 sDataType = aoColumns[ aDataSort[k] ].sType;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4002 fnSortFormat = oSort[ (sDataType ? sDataType : 'string')+"-pre" ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4003
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4004 aoData[i]._aSortData[ aDataSort[k] ] = fnSortFormat ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4005 fnSortFormat( _fnGetCellData( oSettings, i, aDataSort[k], 'sort' ) ) :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4006 _fnGetCellData( oSettings, i, aDataSort[k], 'sort' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4007 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4008 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4009 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4010
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4011 /* Do the sort - here we want multi-column sorting based on a given data source (column)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4012 * and sorting function (from oSort) in a certain direction. It's reasonably complex to
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4013 * follow on it's own, but this is what we want (example two column sorting):
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4014 * fnLocalSorting = function(a,b){
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4015 * var iTest;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4016 * iTest = oSort['string-asc']('data11', 'data12');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4017 * if (iTest !== 0)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4018 * return iTest;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4019 * iTest = oSort['numeric-desc']('data21', 'data22');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4020 * if (iTest !== 0)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4021 * return iTest;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4022 * return oSort['numeric-asc']( aiOrig[a], aiOrig[b] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4023 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4024 * Basically we have a test for each sorting column, if the data in that column is equal,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4025 * test the next column. If all columns match, then we use a numeric sort on the row
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4026 * positions in the original data array to provide a stable sort.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4027 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4028 oSettings.aiDisplayMaster.sort( function ( a, b ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4029 var k, l, lLen, iTest, aDataSort, sDataType;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4030 for ( k=0 ; k<iSortLen ; k++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4031 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4032 aDataSort = aoColumns[ aaSort[k][0] ].aDataSort;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4033
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4034 for ( l=0, lLen=aDataSort.length ; l<lLen ; l++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4035 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4036 sDataType = aoColumns[ aDataSort[l] ].sType;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4037
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4038 iTest = oSort[ (sDataType ? sDataType : 'string')+"-"+aaSort[k][1] ](
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4039 aoData[a]._aSortData[ aDataSort[l] ],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4040 aoData[b]._aSortData[ aDataSort[l] ]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4041 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4042
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4043 if ( iTest !== 0 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4044 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4045 return iTest;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4046 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4047 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4048 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4049
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4050 return oSort['numeric-asc']( aiOrig[a], aiOrig[b] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4051 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4052 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4053
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4054 /* Alter the sorting classes to take account of the changes */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4055 if ( (bApplyClasses === undefined || bApplyClasses) && !oSettings.oFeatures.bDeferRender )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4056 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4057 _fnSortingClasses( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4058 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4059
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4060 for ( i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4061 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4062 var sTitle = aoColumns[i].sTitle.replace( /<.*?>/g, "" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4063 nTh = aoColumns[i].nTh;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4064 nTh.removeAttribute('aria-sort');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4065 nTh.removeAttribute('aria-label');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4066
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4067 /* In ARIA only the first sorting column can be marked as sorting - no multi-sort option */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4068 if ( aoColumns[i].bSortable )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4069 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4070 if ( aaSort.length > 0 && aaSort[0][0] == i )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4071 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4072 nTh.setAttribute('aria-sort', aaSort[0][1]=="asc" ? "ascending" : "descending" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4073
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4074 var nextSort = (aoColumns[i].asSorting[ aaSort[0][2]+1 ]) ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4075 aoColumns[i].asSorting[ aaSort[0][2]+1 ] : aoColumns[i].asSorting[0];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4076 nTh.setAttribute('aria-label', sTitle+
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4077 (nextSort=="asc" ? oAria.sSortAscending : oAria.sSortDescending) );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4078 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4079 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4080 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4081 nTh.setAttribute('aria-label', sTitle+
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4082 (aoColumns[i].asSorting[0]=="asc" ? oAria.sSortAscending : oAria.sSortDescending) );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4083 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4084 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4085 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4086 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4087 nTh.setAttribute('aria-label', sTitle);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4088 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4089 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4090
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4091 /* Tell the draw function that we have sorted the data */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4092 oSettings.bSorted = true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4093 $(oSettings.oInstance).trigger('sort', oSettings);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4094
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4095 /* Copy the master data into the draw array and re-draw */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4096 if ( oSettings.oFeatures.bFilter )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4097 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4098 /* _fnFilter() will redraw the table for us */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4099 _fnFilterComplete( oSettings, oSettings.oPreviousSearch, 1 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4100 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4101 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4102 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4103 oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4104 oSettings._iDisplayStart = 0; /* reset display back to page 0 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4105 _fnCalculateEnd( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4106 _fnDraw( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4107 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4108 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4109
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4110
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4111 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4112 * Attach a sort handler (click) to a node
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4113 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4114 * @param {node} nNode node to attach the handler to
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4115 * @param {int} iDataIndex column sorting index
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4116 * @param {function} [fnCallback] callback function
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4117 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4118 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4119 function _fnSortAttachListener ( oSettings, nNode, iDataIndex, fnCallback )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4120 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4121 _fnBindAction( nNode, {}, function (e) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4122 /* If the column is not sortable - don't to anything */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4123 if ( oSettings.aoColumns[iDataIndex].bSortable === false )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4124 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4125 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4126 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4127
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4128 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4129 * This is a little bit odd I admit... I declare a temporary function inside the scope of
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4130 * _fnBuildHead and the click handler in order that the code presented here can be used
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4131 * twice - once for when bProcessing is enabled, and another time for when it is
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4132 * disabled, as we need to perform slightly different actions.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4133 * Basically the issue here is that the Javascript engine in modern browsers don't
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4134 * appear to allow the rendering engine to update the display while it is still executing
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4135 * it's thread (well - it does but only after long intervals). This means that the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4136 * 'processing' display doesn't appear for a table sort. To break the js thread up a bit
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4137 * I force an execution break by using setTimeout - but this breaks the expected
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4138 * thread continuation for the end-developer's point of view (their code would execute
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4139 * too early), so we only do it when we absolutely have to.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4140 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4141 var fnInnerSorting = function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4142 var iColumn, iNextSort;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4143
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4144 /* If the shift key is pressed then we are multiple column sorting */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4145 if ( e.shiftKey )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4146 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4147 /* Are we already doing some kind of sort on this column? */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4148 var bFound = false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4149 for ( var i=0 ; i<oSettings.aaSorting.length ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4150 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4151 if ( oSettings.aaSorting[i][0] == iDataIndex )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4152 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4153 bFound = true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4154 iColumn = oSettings.aaSorting[i][0];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4155 iNextSort = oSettings.aaSorting[i][2]+1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4156
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4157 if ( !oSettings.aoColumns[iColumn].asSorting[iNextSort] )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4158 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4159 /* Reached the end of the sorting options, remove from multi-col sort */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4160 oSettings.aaSorting.splice( i, 1 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4161 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4162 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4163 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4164 /* Move onto next sorting direction */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4165 oSettings.aaSorting[i][1] = oSettings.aoColumns[iColumn].asSorting[iNextSort];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4166 oSettings.aaSorting[i][2] = iNextSort;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4167 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4168 break;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4169 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4170 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4171
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4172 /* No sort yet - add it in */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4173 if ( bFound === false )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4174 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4175 oSettings.aaSorting.push( [ iDataIndex,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4176 oSettings.aoColumns[iDataIndex].asSorting[0], 0 ] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4177 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4178 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4179 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4180 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4181 /* If no shift key then single column sort */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4182 if ( oSettings.aaSorting.length == 1 && oSettings.aaSorting[0][0] == iDataIndex )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4183 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4184 iColumn = oSettings.aaSorting[0][0];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4185 iNextSort = oSettings.aaSorting[0][2]+1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4186 if ( !oSettings.aoColumns[iColumn].asSorting[iNextSort] )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4187 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4188 iNextSort = 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4189 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4190 oSettings.aaSorting[0][1] = oSettings.aoColumns[iColumn].asSorting[iNextSort];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4191 oSettings.aaSorting[0][2] = iNextSort;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4192 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4193 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4194 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4195 oSettings.aaSorting.splice( 0, oSettings.aaSorting.length );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4196 oSettings.aaSorting.push( [ iDataIndex,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4197 oSettings.aoColumns[iDataIndex].asSorting[0], 0 ] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4198 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4199 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4200
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4201 /* Run the sort */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4202 _fnSort( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4203 }; /* /fnInnerSorting */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4204
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4205 if ( !oSettings.oFeatures.bProcessing )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4206 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4207 fnInnerSorting();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4208 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4209 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4210 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4211 _fnProcessingDisplay( oSettings, true );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4212 setTimeout( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4213 fnInnerSorting();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4214 if ( !oSettings.oFeatures.bServerSide )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4215 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4216 _fnProcessingDisplay( oSettings, false );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4217 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4218 }, 0 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4219 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4220
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4221 /* Call the user specified callback function - used for async user interaction */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4222 if ( typeof fnCallback == 'function' )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4223 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4224 fnCallback( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4225 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4226 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4227 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4228
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4229
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4230 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4231 * Set the sorting classes on the header, Note: it is safe to call this function
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4232 * when bSort and bSortClasses are false
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4233 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4234 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4235 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4236 function _fnSortingClasses( oSettings )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4237 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4238 var i, iLen, j, jLen, iFound;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4239 var aaSort, sClass;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4240 var iColumns = oSettings.aoColumns.length;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4241 var oClasses = oSettings.oClasses;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4242
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4243 for ( i=0 ; i<iColumns ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4244 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4245 if ( oSettings.aoColumns[i].bSortable )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4246 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4247 $(oSettings.aoColumns[i].nTh).removeClass( oClasses.sSortAsc +" "+ oClasses.sSortDesc +
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4248 " "+ oSettings.aoColumns[i].sSortingClass );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4249 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4250 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4251
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4252 if ( oSettings.aaSortingFixed !== null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4253 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4254 aaSort = oSettings.aaSortingFixed.concat( oSettings.aaSorting );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4255 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4256 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4257 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4258 aaSort = oSettings.aaSorting.slice();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4259 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4260
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4261 /* Apply the required classes to the header */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4262 for ( i=0 ; i<oSettings.aoColumns.length ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4263 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4264 if ( oSettings.aoColumns[i].bSortable )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4265 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4266 sClass = oSettings.aoColumns[i].sSortingClass;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4267 iFound = -1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4268 for ( j=0 ; j<aaSort.length ; j++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4269 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4270 if ( aaSort[j][0] == i )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4271 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4272 sClass = ( aaSort[j][1] == "asc" ) ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4273 oClasses.sSortAsc : oClasses.sSortDesc;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4274 iFound = j;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4275 break;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4276 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4277 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4278 $(oSettings.aoColumns[i].nTh).addClass( sClass );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4279
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4280 if ( oSettings.bJUI )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4281 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4282 /* jQuery UI uses extra markup */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4283 var jqSpan = $("span."+oClasses.sSortIcon, oSettings.aoColumns[i].nTh);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4284 jqSpan.removeClass(oClasses.sSortJUIAsc +" "+ oClasses.sSortJUIDesc +" "+
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4285 oClasses.sSortJUI +" "+ oClasses.sSortJUIAscAllowed +" "+ oClasses.sSortJUIDescAllowed );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4286
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4287 var sSpanClass;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4288 if ( iFound == -1 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4289 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4290 sSpanClass = oSettings.aoColumns[i].sSortingClassJUI;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4291 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4292 else if ( aaSort[iFound][1] == "asc" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4293 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4294 sSpanClass = oClasses.sSortJUIAsc;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4295 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4296 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4297 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4298 sSpanClass = oClasses.sSortJUIDesc;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4299 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4300
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4301 jqSpan.addClass( sSpanClass );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4302 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4303 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4304 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4305 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4306 /* No sorting on this column, so add the base class. This will have been assigned by
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4307 * _fnAddColumn
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4308 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4309 $(oSettings.aoColumns[i].nTh).addClass( oSettings.aoColumns[i].sSortingClass );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4310 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4311 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4312
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4313 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4314 * Apply the required classes to the table body
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4315 * Note that this is given as a feature switch since it can significantly slow down a sort
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4316 * on large data sets (adding and removing of classes is always slow at the best of times..)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4317 * Further to this, note that this code is admittedly fairly ugly. It could be made a lot
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4318 * simpler using jQuery selectors and add/removeClass, but that is significantly slower
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4319 * (on the order of 5 times slower) - hence the direct DOM manipulation here.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4320 * Note that for deferred drawing we do use jQuery - the reason being that taking the first
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4321 * row found to see if the whole column needs processed can miss classes since the first
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4322 * column might be new.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4323 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4324 sClass = oClasses.sSortColumn;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4325
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4326 if ( oSettings.oFeatures.bSort && oSettings.oFeatures.bSortClasses )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4327 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4328 var nTds = _fnGetTdNodes( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4329
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4330 /* Determine what the sorting class for each column should be */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4331 var iClass, iTargetCol;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4332 var asClasses = [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4333 for (i = 0; i < iColumns; i++)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4334 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4335 asClasses.push("");
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4336 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4337 for (i = 0, iClass = 1; i < aaSort.length; i++)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4338 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4339 iTargetCol = parseInt( aaSort[i][0], 10 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4340 asClasses[iTargetCol] = sClass + iClass;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4341
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4342 if ( iClass < 3 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4343 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4344 iClass++;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4345 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4346 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4347
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4348 /* Make changes to the classes for each cell as needed */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4349 var reClass = new RegExp(sClass + "[123]");
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4350 var sTmpClass, sCurrentClass, sNewClass;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4351 for ( i=0, iLen=nTds.length; i<iLen; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4352 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4353 /* Determine which column we're looking at */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4354 iTargetCol = i % iColumns;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4355
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4356 /* What is the full list of classes now */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4357 sCurrentClass = nTds[i].className;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4358 /* What sorting class should be applied? */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4359 sNewClass = asClasses[iTargetCol];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4360 /* What would the new full list be if we did a replacement? */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4361 sTmpClass = sCurrentClass.replace(reClass, sNewClass);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4362
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4363 if ( sTmpClass != sCurrentClass )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4364 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4365 /* We changed something */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4366 nTds[i].className = $.trim( sTmpClass );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4367 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4368 else if ( sNewClass.length > 0 && sCurrentClass.indexOf(sNewClass) == -1 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4369 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4370 /* We need to add a class */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4371 nTds[i].className = sCurrentClass + " " + sNewClass;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4372 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4373 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4374 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4375 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4376
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4377
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4378
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4379 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4380 * Save the state of a table in a cookie such that the page can be reloaded
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4381 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4382 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4383 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4384 function _fnSaveState ( oSettings )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4385 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4386 if ( !oSettings.oFeatures.bStateSave || oSettings.bDestroying )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4387 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4388 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4389 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4390
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4391 /* Store the interesting variables */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4392 var i, iLen, bInfinite=oSettings.oScroll.bInfinite;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4393 var oState = {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4394 "iCreate": new Date().getTime(),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4395 "iStart": (bInfinite ? 0 : oSettings._iDisplayStart),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4396 "iEnd": (bInfinite ? oSettings._iDisplayLength : oSettings._iDisplayEnd),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4397 "iLength": oSettings._iDisplayLength,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4398 "aaSorting": $.extend( true, [], oSettings.aaSorting ),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4399 "oSearch": $.extend( true, {}, oSettings.oPreviousSearch ),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4400 "aoSearchCols": $.extend( true, [], oSettings.aoPreSearchCols ),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4401 "abVisCols": []
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4402 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4403
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4404 for ( i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4405 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4406 oState.abVisCols.push( oSettings.aoColumns[i].bVisible );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4407 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4408
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4409 _fnCallbackFire( oSettings, "aoStateSaveParams", 'stateSaveParams', [oSettings, oState] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4410
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4411 oSettings.fnStateSave.call( oSettings.oInstance, oSettings, oState );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4412 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4413
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4414
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4415 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4416 * Attempt to load a saved table state from a cookie
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4417 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4418 * @param {object} oInit DataTables init object so we can override settings
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4419 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4420 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4421 function _fnLoadState ( oSettings, oInit )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4422 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4423 if ( !oSettings.oFeatures.bStateSave )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4424 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4425 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4426 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4427
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4428 var oData = oSettings.fnStateLoad.call( oSettings.oInstance, oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4429 if ( !oData )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4430 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4431 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4432 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4433
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4434 /* Allow custom and plug-in manipulation functions to alter the saved data set and
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4435 * cancelling of loading by returning false
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4436 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4437 var abStateLoad = _fnCallbackFire( oSettings, 'aoStateLoadParams', 'stateLoadParams', [oSettings, oData] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4438 if ( $.inArray( false, abStateLoad ) !== -1 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4439 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4440 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4441 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4442
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4443 /* Store the saved state so it might be accessed at any time */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4444 oSettings.oLoadedState = $.extend( true, {}, oData );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4445
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4446 /* Restore key features */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4447 oSettings._iDisplayStart = oData.iStart;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4448 oSettings.iInitDisplayStart = oData.iStart;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4449 oSettings._iDisplayEnd = oData.iEnd;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4450 oSettings._iDisplayLength = oData.iLength;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4451 oSettings.aaSorting = oData.aaSorting.slice();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4452 oSettings.saved_aaSorting = oData.aaSorting.slice();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4453
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4454 /* Search filtering */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4455 $.extend( oSettings.oPreviousSearch, oData.oSearch );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4456 $.extend( true, oSettings.aoPreSearchCols, oData.aoSearchCols );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4457
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4458 /* Column visibility state
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4459 * Pass back visibility settings to the init handler, but to do not here override
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4460 * the init object that the user might have passed in
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4461 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4462 oInit.saved_aoColumns = [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4463 for ( var i=0 ; i<oData.abVisCols.length ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4464 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4465 oInit.saved_aoColumns[i] = {};
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4466 oInit.saved_aoColumns[i].bVisible = oData.abVisCols[i];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4467 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4468
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4469 _fnCallbackFire( oSettings, 'aoStateLoaded', 'stateLoaded', [oSettings, oData] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4470 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4471
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4472
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4473 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4474 * Create a new cookie with a value to store the state of a table
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4475 * @param {string} sName name of the cookie to create
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4476 * @param {string} sValue the value the cookie should take
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4477 * @param {int} iSecs duration of the cookie
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4478 * @param {string} sBaseName sName is made up of the base + file name - this is the base
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4479 * @param {function} fnCallback User definable function to modify the cookie
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4480 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4481 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4482 function _fnCreateCookie ( sName, sValue, iSecs, sBaseName, fnCallback )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4483 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4484 var date = new Date();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4485 date.setTime( date.getTime()+(iSecs*1000) );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4486
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4487 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4488 * Shocking but true - it would appear IE has major issues with having the path not having
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4489 * a trailing slash on it. We need the cookie to be available based on the path, so we
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4490 * have to append the file name to the cookie name. Appalling. Thanks to vex for adding the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4491 * patch to use at least some of the path
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4492 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4493 var aParts = window.location.pathname.split('/');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4494 var sNameFile = sName + '_' + aParts.pop().replace(/[\/:]/g,"").toLowerCase();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4495 var sFullCookie, oData;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4496
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4497 if ( fnCallback !== null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4498 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4499 oData = (typeof $.parseJSON === 'function') ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4500 $.parseJSON( sValue ) : eval( '('+sValue+')' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4501 sFullCookie = fnCallback( sNameFile, oData, date.toGMTString(),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4502 aParts.join('/')+"/" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4503 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4504 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4505 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4506 sFullCookie = sNameFile + "=" + encodeURIComponent(sValue) +
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4507 "; expires=" + date.toGMTString() +"; path=" + aParts.join('/')+"/";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4508 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4509
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4510 /* Are we going to go over the cookie limit of 4KiB? If so, try to delete a cookies
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4511 * belonging to DataTables.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4512 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4513 var
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4514 aCookies =document.cookie.split(';'),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4515 iNewCookieLen = sFullCookie.split(';')[0].length,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4516 aOldCookies = [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4517
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4518 if ( iNewCookieLen+document.cookie.length+10 > 4096 ) /* Magic 10 for padding */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4519 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4520 for ( var i=0, iLen=aCookies.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4521 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4522 if ( aCookies[i].indexOf( sBaseName ) != -1 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4523 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4524 /* It's a DataTables cookie, so eval it and check the time stamp */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4525 var aSplitCookie = aCookies[i].split('=');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4526 try {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4527 oData = eval( '('+decodeURIComponent(aSplitCookie[1])+')' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4528
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4529 if ( oData && oData.iCreate )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4530 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4531 aOldCookies.push( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4532 "name": aSplitCookie[0],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4533 "time": oData.iCreate
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4534 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4535 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4536 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4537 catch( e ) {}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4538 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4539 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4540
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4541 // Make sure we delete the oldest ones first
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4542 aOldCookies.sort( function (a, b) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4543 return b.time - a.time;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4544 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4545
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4546 // Eliminate as many old DataTables cookies as we need to
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4547 while ( iNewCookieLen + document.cookie.length + 10 > 4096 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4548 if ( aOldCookies.length === 0 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4549 // Deleted all DT cookies and still not enough space. Can't state save
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4550 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4551 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4552
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4553 var old = aOldCookies.pop();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4554 document.cookie = old.name+"=; expires=Thu, 01-Jan-1970 00:00:01 GMT; path="+
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4555 aParts.join('/') + "/";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4556 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4557 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4558
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4559 document.cookie = sFullCookie;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4560 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4561
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4562
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4563 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4564 * Read an old cookie to get a cookie with an old table state
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4565 * @param {string} sName name of the cookie to read
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4566 * @returns {string} contents of the cookie - or null if no cookie with that name found
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4567 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4568 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4569 function _fnReadCookie ( sName )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4570 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4571 var
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4572 aParts = window.location.pathname.split('/'),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4573 sNameEQ = sName + '_' + aParts[aParts.length-1].replace(/[\/:]/g,"").toLowerCase() + '=',
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4574 sCookieContents = document.cookie.split(';');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4575
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4576 for( var i=0 ; i<sCookieContents.length ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4577 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4578 var c = sCookieContents[i];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4579
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4580 while (c.charAt(0)==' ')
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4581 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4582 c = c.substring(1,c.length);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4583 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4584
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4585 if (c.indexOf(sNameEQ) === 0)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4586 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4587 return decodeURIComponent( c.substring(sNameEQ.length,c.length) );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4588 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4589 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4590 return null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4591 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4592
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4593
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4594 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4595 * Return the settings object for a particular table
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4596 * @param {node} nTable table we are using as a dataTable
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4597 * @returns {object} Settings object - or null if not found
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4598 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4599 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4600 function _fnSettingsFromNode ( nTable )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4601 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4602 for ( var i=0 ; i<DataTable.settings.length ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4603 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4604 if ( DataTable.settings[i].nTable === nTable )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4605 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4606 return DataTable.settings[i];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4607 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4608 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4609
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4610 return null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4611 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4612
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4613
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4614 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4615 * Return an array with the TR nodes for the table
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4616 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4617 * @returns {array} TR array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4618 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4619 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4620 function _fnGetTrNodes ( oSettings )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4621 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4622 var aNodes = [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4623 var aoData = oSettings.aoData;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4624 for ( var i=0, iLen=aoData.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4625 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4626 if ( aoData[i].nTr !== null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4627 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4628 aNodes.push( aoData[i].nTr );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4629 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4630 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4631 return aNodes;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4632 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4633
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4634
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4635 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4636 * Return an flat array with all TD nodes for the table, or row
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4637 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4638 * @param {int} [iIndividualRow] aoData index to get the nodes for - optional
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4639 * if not given then the return array will contain all nodes for the table
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4640 * @returns {array} TD array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4641 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4642 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4643 function _fnGetTdNodes ( oSettings, iIndividualRow )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4644 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4645 var anReturn = [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4646 var iCorrector;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4647 var anTds, nTd;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4648 var iRow, iRows=oSettings.aoData.length,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4649 iColumn, iColumns, oData, sNodeName, iStart=0, iEnd=iRows;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4650
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4651 /* Allow the collection to be limited to just one row */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4652 if ( iIndividualRow !== undefined )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4653 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4654 iStart = iIndividualRow;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4655 iEnd = iIndividualRow+1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4656 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4657
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4658 for ( iRow=iStart ; iRow<iEnd ; iRow++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4659 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4660 oData = oSettings.aoData[iRow];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4661 if ( oData.nTr !== null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4662 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4663 /* get the TD child nodes - taking into account text etc nodes */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4664 anTds = [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4665 nTd = oData.nTr.firstChild;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4666 while ( nTd )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4667 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4668 sNodeName = nTd.nodeName.toLowerCase();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4669 if ( sNodeName == 'td' || sNodeName == 'th' )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4670 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4671 anTds.push( nTd );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4672 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4673 nTd = nTd.nextSibling;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4674 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4675
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4676 iCorrector = 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4677 for ( iColumn=0, iColumns=oSettings.aoColumns.length ; iColumn<iColumns ; iColumn++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4678 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4679 if ( oSettings.aoColumns[iColumn].bVisible )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4680 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4681 anReturn.push( anTds[iColumn-iCorrector] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4682 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4683 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4684 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4685 anReturn.push( oData._anHidden[iColumn] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4686 iCorrector++;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4687 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4688 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4689 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4690 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4691
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4692 return anReturn;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4693 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4694
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4695
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4696 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4697 * Log an error message
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4698 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4699 * @param {int} iLevel log error messages, or display them to the user
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4700 * @param {string} sMesg error message
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4701 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4702 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4703 function _fnLog( oSettings, iLevel, sMesg )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4704 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4705 var sAlert = (oSettings===null) ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4706 "DataTables warning: "+sMesg :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4707 "DataTables warning (table id = '"+oSettings.sTableId+"'): "+sMesg;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4708
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4709 if ( iLevel === 0 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4710 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4711 if ( DataTable.ext.sErrMode == 'alert' )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4712 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4713 alert( sAlert );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4714 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4715 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4716 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4717 throw new Error(sAlert);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4718 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4719 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4720 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4721 else if ( window.console && console.log )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4722 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4723 console.log( sAlert );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4724 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4725 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4726
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4727
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4728 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4729 * See if a property is defined on one object, if so assign it to the other object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4730 * @param {object} oRet target object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4731 * @param {object} oSrc source object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4732 * @param {string} sName property
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4733 * @param {string} [sMappedName] name to map too - optional, sName used if not given
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4734 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4735 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4736 function _fnMap( oRet, oSrc, sName, sMappedName )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4737 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4738 if ( sMappedName === undefined )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4739 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4740 sMappedName = sName;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4741 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4742 if ( oSrc[sName] !== undefined )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4743 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4744 oRet[sMappedName] = oSrc[sName];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4745 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4746 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4747
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4748
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4749 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4750 * Extend objects - very similar to jQuery.extend, but deep copy objects, and shallow
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4751 * copy arrays. The reason we need to do this, is that we don't want to deep copy array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4752 * init values (such as aaSorting) since the dev wouldn't be able to override them, but
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4753 * we do want to deep copy arrays.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4754 * @param {object} oOut Object to extend
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4755 * @param {object} oExtender Object from which the properties will be applied to oOut
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4756 * @returns {object} oOut Reference, just for convenience - oOut === the return.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4757 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4758 * @todo This doesn't take account of arrays inside the deep copied objects.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4759 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4760 function _fnExtend( oOut, oExtender )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4761 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4762 var val;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4763
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4764 for ( var prop in oExtender )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4765 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4766 if ( oExtender.hasOwnProperty(prop) )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4767 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4768 val = oExtender[prop];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4769
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4770 if ( typeof oInit[prop] === 'object' && val !== null && $.isArray(val) === false )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4771 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4772 $.extend( true, oOut[prop], val );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4773 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4774 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4775 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4776 oOut[prop] = val;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4777 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4778 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4779 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4780
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4781 return oOut;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4782 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4783
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4784
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4785 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4786 * Bind an event handers to allow a click or return key to activate the callback.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4787 * This is good for accessibility since a return on the keyboard will have the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4788 * same effect as a click, if the element has focus.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4789 * @param {element} n Element to bind the action to
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4790 * @param {object} oData Data object to pass to the triggered function
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4791 * @param {function} fn Callback function for when the event is triggered
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4792 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4793 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4794 function _fnBindAction( n, oData, fn )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4795 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4796 $(n)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4797 .bind( 'click.DT', oData, function (e) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4798 n.blur(); // Remove focus outline for mouse users
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4799 fn(e);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4800 } )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4801 .bind( 'keypress.DT', oData, function (e){
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4802 if ( e.which === 13 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4803 fn(e);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4804 } } )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4805 .bind( 'selectstart.DT', function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4806 /* Take the brutal approach to cancelling text selection */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4807 return false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4808 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4809 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4810
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4811
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4812 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4813 * Register a callback function. Easily allows a callback function to be added to
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4814 * an array store of callback functions that can then all be called together.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4815 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4816 * @param {string} sStore Name of the array storage for the callbacks in oSettings
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4817 * @param {function} fn Function to be called back
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4818 * @param {string} sName Identifying name for the callback (i.e. a label)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4819 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4820 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4821 function _fnCallbackReg( oSettings, sStore, fn, sName )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4822 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4823 if ( fn )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4824 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4825 oSettings[sStore].push( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4826 "fn": fn,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4827 "sName": sName
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4828 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4829 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4830 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4831
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4832
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4833 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4834 * Fire callback functions and trigger events. Note that the loop over the callback
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4835 * array store is done backwards! Further note that you do not want to fire off triggers
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4836 * in time sensitive applications (for example cell creation) as its slow.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4837 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4838 * @param {string} sStore Name of the array storage for the callbacks in oSettings
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4839 * @param {string} sTrigger Name of the jQuery custom event to trigger. If null no trigger
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4840 * is fired
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4841 * @param {array} aArgs Array of arguments to pass to the callback function / trigger
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4842 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4843 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4844 function _fnCallbackFire( oSettings, sStore, sTrigger, aArgs )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4845 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4846 var aoStore = oSettings[sStore];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4847 var aRet =[];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4848
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4849 for ( var i=aoStore.length-1 ; i>=0 ; i-- )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4850 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4851 aRet.push( aoStore[i].fn.apply( oSettings.oInstance, aArgs ) );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4852 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4853
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4854 if ( sTrigger !== null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4855 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4856 $(oSettings.oInstance).trigger(sTrigger, aArgs);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4857 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4858
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4859 return aRet;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4860 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4861
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4862
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4863 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4864 * JSON stringify. If JSON.stringify it provided by the browser, json2.js or any other
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4865 * library, then we use that as it is fast, safe and accurate. If the function isn't
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4866 * available then we need to built it ourselves - the inspiration for this function comes
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4867 * from Craig Buckler ( http://www.sitepoint.com/javascript-json-serialization/ ). It is
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4868 * not perfect and absolutely should not be used as a replacement to json2.js - but it does
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4869 * do what we need, without requiring a dependency for DataTables.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4870 * @param {object} o JSON object to be converted
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4871 * @returns {string} JSON string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4872 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4873 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4874 var _fnJsonString = (window.JSON) ? JSON.stringify : function( o )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4875 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4876 /* Not an object or array */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4877 var sType = typeof o;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4878 if (sType !== "object" || o === null)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4879 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4880 // simple data type
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4881 if (sType === "string")
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4882 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4883 o = '"'+o+'"';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4884 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4885 return o+"";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4886 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4887
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4888 /* If object or array, need to recurse over it */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4889 var
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4890 sProp, mValue,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4891 json = [],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4892 bArr = $.isArray(o);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4893
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4894 for (sProp in o)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4895 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4896 mValue = o[sProp];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4897 sType = typeof mValue;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4898
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4899 if (sType === "string")
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4900 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4901 mValue = '"'+mValue+'"';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4902 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4903 else if (sType === "object" && mValue !== null)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4904 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4905 mValue = _fnJsonString(mValue);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4906 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4907
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4908 json.push((bArr ? "" : '"'+sProp+'":') + mValue);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4909 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4910
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4911 return (bArr ? "[" : "{") + json + (bArr ? "]" : "}");
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4912 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4913
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4914
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4915 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4916 * From some browsers (specifically IE6/7) we need special handling to work around browser
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4917 * bugs - this function is used to detect when these workarounds are needed.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4918 * @param {object} oSettings dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4919 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4920 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4921 function _fnBrowserDetect( oSettings )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4922 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4923 /* IE6/7 will oversize a width 100% element inside a scrolling element, to include the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4924 * width of the scrollbar, while other browsers ensure the inner element is contained
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4925 * without forcing scrolling
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4926 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4927 var n = $(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4928 '<div style="position:absolute; top:0; left:0; height:1px; width:1px; overflow:hidden">'+
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4929 '<div style="position:absolute; top:1px; left:1px; width:100px; overflow:scroll;">'+
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4930 '<div id="DT_BrowserTest" style="width:100%; height:10px;"></div>'+
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4931 '</div>'+
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4932 '</div>')[0];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4933
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4934 document.body.appendChild( n );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4935 oSettings.oBrowser.bScrollOversize = $('#DT_BrowserTest', n)[0].offsetWidth === 100 ? true : false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4936 document.body.removeChild( n );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4937 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4938
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4939
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4940 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4941 * Perform a jQuery selector action on the table's TR elements (from the tbody) and
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4942 * return the resulting jQuery object.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4943 * @param {string|node|jQuery} sSelector jQuery selector or node collection to act on
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4944 * @param {object} [oOpts] Optional parameters for modifying the rows to be included
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4945 * @param {string} [oOpts.filter=none] Select TR elements that meet the current filter
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4946 * criterion ("applied") or all TR elements (i.e. no filter).
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4947 * @param {string} [oOpts.order=current] Order of the TR elements in the processed array.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4948 * Can be either 'current', whereby the current sorting of the table is used, or
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4949 * 'original' whereby the original order the data was read into the table is used.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4950 * @param {string} [oOpts.page=all] Limit the selection to the currently displayed page
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4951 * ("current") or not ("all"). If 'current' is given, then order is assumed to be
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4952 * 'current' and filter is 'applied', regardless of what they might be given as.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4953 * @returns {object} jQuery object, filtered by the given selector.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4954 * @dtopt API
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4955 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4956 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4957 * $(document).ready(function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4958 * var oTable = $('#example').dataTable();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4959 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4960 * // Highlight every second row
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4961 * oTable.$('tr:odd').css('backgroundColor', 'blue');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4962 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4963 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4964 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4965 * $(document).ready(function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4966 * var oTable = $('#example').dataTable();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4967 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4968 * // Filter to rows with 'Webkit' in them, add a background colour and then
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4969 * // remove the filter, thus highlighting the 'Webkit' rows only.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4970 * oTable.fnFilter('Webkit');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4971 * oTable.$('tr', {"filter": "applied"}).css('backgroundColor', 'blue');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4972 * oTable.fnFilter('');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4973 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4974 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4975 this.$ = function ( sSelector, oOpts )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4976 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4977 var i, iLen, a = [], tr;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4978 var oSettings = _fnSettingsFromNode( this[DataTable.ext.iApiIndex] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4979 var aoData = oSettings.aoData;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4980 var aiDisplay = oSettings.aiDisplay;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4981 var aiDisplayMaster = oSettings.aiDisplayMaster;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4982
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4983 if ( !oOpts )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4984 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4985 oOpts = {};
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4986 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4987
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4988 oOpts = $.extend( {}, {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4989 "filter": "none", // applied
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4990 "order": "current", // "original"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4991 "page": "all" // current
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4992 }, oOpts );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4993
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4994 // Current page implies that order=current and fitler=applied, since it is fairly
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4995 // senseless otherwise
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4996 if ( oOpts.page == 'current' )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4997 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4998 for ( i=oSettings._iDisplayStart, iLen=oSettings.fnDisplayEnd() ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4999 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5000 tr = aoData[ aiDisplay[i] ].nTr;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5001 if ( tr )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5002 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5003 a.push( tr );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5004 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5005 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5006 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5007 else if ( oOpts.order == "current" && oOpts.filter == "none" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5008 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5009 for ( i=0, iLen=aiDisplayMaster.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5010 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5011 tr = aoData[ aiDisplayMaster[i] ].nTr;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5012 if ( tr )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5013 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5014 a.push( tr );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5015 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5016 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5017 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5018 else if ( oOpts.order == "current" && oOpts.filter == "applied" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5019 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5020 for ( i=0, iLen=aiDisplay.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5021 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5022 tr = aoData[ aiDisplay[i] ].nTr;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5023 if ( tr )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5024 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5025 a.push( tr );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5026 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5027 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5028 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5029 else if ( oOpts.order == "original" && oOpts.filter == "none" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5030 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5031 for ( i=0, iLen=aoData.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5032 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5033 tr = aoData[ i ].nTr ;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5034 if ( tr )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5035 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5036 a.push( tr );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5037 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5038 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5039 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5040 else if ( oOpts.order == "original" && oOpts.filter == "applied" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5041 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5042 for ( i=0, iLen=aoData.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5043 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5044 tr = aoData[ i ].nTr;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5045 if ( $.inArray( i, aiDisplay ) !== -1 && tr )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5046 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5047 a.push( tr );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5048 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5049 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5050 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5051 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5052 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5053 _fnLog( oSettings, 1, "Unknown selection options" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5054 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5055
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5056 /* We need to filter on the TR elements and also 'find' in their descendants
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5057 * to make the selector act like it would in a full table - so we need
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5058 * to build both results and then combine them together
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5059 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5060 var jqA = $(a);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5061 var jqTRs = jqA.filter( sSelector );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5062 var jqDescendants = jqA.find( sSelector );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5063
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5064 return $( [].concat($.makeArray(jqTRs), $.makeArray(jqDescendants)) );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5065 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5066
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5067
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5068 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5069 * Almost identical to $ in operation, but in this case returns the data for the matched
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5070 * rows - as such, the jQuery selector used should match TR row nodes or TD/TH cell nodes
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5071 * rather than any descendants, so the data can be obtained for the row/cell. If matching
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5072 * rows are found, the data returned is the original data array/object that was used to
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5073 * create the row (or a generated array if from a DOM source).
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5074 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5075 * This method is often useful in-combination with $ where both functions are given the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5076 * same parameters and the array indexes will match identically.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5077 * @param {string|node|jQuery} sSelector jQuery selector or node collection to act on
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5078 * @param {object} [oOpts] Optional parameters for modifying the rows to be included
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5079 * @param {string} [oOpts.filter=none] Select elements that meet the current filter
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5080 * criterion ("applied") or all elements (i.e. no filter).
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5081 * @param {string} [oOpts.order=current] Order of the data in the processed array.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5082 * Can be either 'current', whereby the current sorting of the table is used, or
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5083 * 'original' whereby the original order the data was read into the table is used.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5084 * @param {string} [oOpts.page=all] Limit the selection to the currently displayed page
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5085 * ("current") or not ("all"). If 'current' is given, then order is assumed to be
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5086 * 'current' and filter is 'applied', regardless of what they might be given as.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5087 * @returns {array} Data for the matched elements. If any elements, as a result of the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5088 * selector, were not TR, TD or TH elements in the DataTable, they will have a null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5089 * entry in the array.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5090 * @dtopt API
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5091 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5092 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5093 * $(document).ready(function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5094 * var oTable = $('#example').dataTable();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5095 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5096 * // Get the data from the first row in the table
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5097 * var data = oTable._('tr:first');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5098 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5099 * // Do something useful with the data
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5100 * alert( "First cell is: "+data[0] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5101 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5102 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5103 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5104 * $(document).ready(function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5105 * var oTable = $('#example').dataTable();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5106 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5107 * // Filter to 'Webkit' and get all data for
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5108 * oTable.fnFilter('Webkit');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5109 * var data = oTable._('tr', {"filter": "applied"});
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5110 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5111 * // Do something with the data
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5112 * alert( data.length+" rows matched the filter" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5113 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5114 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5115 this._ = function ( sSelector, oOpts )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5116 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5117 var aOut = [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5118 var i, iLen, iIndex;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5119 var aTrs = this.$( sSelector, oOpts );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5120
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5121 for ( i=0, iLen=aTrs.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5122 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5123 aOut.push( this.fnGetData(aTrs[i]) );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5124 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5125
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5126 return aOut;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5127 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5128
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5129
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5130 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5131 * Add a single new row or multiple rows of data to the table. Please note
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5132 * that this is suitable for client-side processing only - if you are using
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5133 * server-side processing (i.e. "bServerSide": true), then to add data, you
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5134 * must add it to the data source, i.e. the server-side, through an Ajax call.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5135 * @param {array|object} mData The data to be added to the table. This can be:
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5136 * <ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5137 * <li>1D array of data - add a single row with the data provided</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5138 * <li>2D array of arrays - add multiple rows in a single call</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5139 * <li>object - data object when using <i>mData</i></li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5140 * <li>array of objects - multiple data objects when using <i>mData</i></li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5141 * </ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5142 * @param {bool} [bRedraw=true] redraw the table or not
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5143 * @returns {array} An array of integers, representing the list of indexes in
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5144 * <i>aoData</i> ({@link DataTable.models.oSettings}) that have been added to
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5145 * the table.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5146 * @dtopt API
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5147 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5148 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5149 * // Global var for counter
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5150 * var giCount = 2;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5151 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5152 * $(document).ready(function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5153 * $('#example').dataTable();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5154 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5155 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5156 * function fnClickAddRow() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5157 * $('#example').dataTable().fnAddData( [
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5158 * giCount+".1",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5159 * giCount+".2",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5160 * giCount+".3",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5161 * giCount+".4" ]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5162 * );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5163 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5164 * giCount++;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5165 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5166 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5167 this.fnAddData = function( mData, bRedraw )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5168 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5169 if ( mData.length === 0 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5170 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5171 return [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5172 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5173
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5174 var aiReturn = [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5175 var iTest;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5176
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5177 /* Find settings from table node */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5178 var oSettings = _fnSettingsFromNode( this[DataTable.ext.iApiIndex] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5179
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5180 /* Check if we want to add multiple rows or not */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5181 if ( typeof mData[0] === "object" && mData[0] !== null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5182 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5183 for ( var i=0 ; i<mData.length ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5184 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5185 iTest = _fnAddData( oSettings, mData[i] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5186 if ( iTest == -1 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5187 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5188 return aiReturn;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5189 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5190 aiReturn.push( iTest );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5191 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5192 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5193 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5194 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5195 iTest = _fnAddData( oSettings, mData );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5196 if ( iTest == -1 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5197 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5198 return aiReturn;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5199 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5200 aiReturn.push( iTest );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5201 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5202
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5203 oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5204
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5205 if ( bRedraw === undefined || bRedraw )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5206 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5207 _fnReDraw( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5208 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5209 return aiReturn;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5210 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5211
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5212
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5213 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5214 * This function will make DataTables recalculate the column sizes, based on the data
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5215 * contained in the table and the sizes applied to the columns (in the DOM, CSS or
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5216 * through the sWidth parameter). This can be useful when the width of the table's
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5217 * parent element changes (for example a window resize).
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5218 * @param {boolean} [bRedraw=true] Redraw the table or not, you will typically want to
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5219 * @dtopt API
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5220 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5221 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5222 * $(document).ready(function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5223 * var oTable = $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5224 * "sScrollY": "200px",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5225 * "bPaginate": false
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5226 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5227 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5228 * $(window).bind('resize', function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5229 * oTable.fnAdjustColumnSizing();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5230 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5231 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5232 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5233 this.fnAdjustColumnSizing = function ( bRedraw )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5234 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5235 var oSettings = _fnSettingsFromNode(this[DataTable.ext.iApiIndex]);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5236 _fnAdjustColumnSizing( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5237
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5238 if ( bRedraw === undefined || bRedraw )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5239 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5240 this.fnDraw( false );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5241 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5242 else if ( oSettings.oScroll.sX !== "" || oSettings.oScroll.sY !== "" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5243 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5244 /* If not redrawing, but scrolling, we want to apply the new column sizes anyway */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5245 this.oApi._fnScrollDraw(oSettings);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5246 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5247 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5248
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5249
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5250 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5251 * Quickly and simply clear a table
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5252 * @param {bool} [bRedraw=true] redraw the table or not
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5253 * @dtopt API
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5254 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5255 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5256 * $(document).ready(function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5257 * var oTable = $('#example').dataTable();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5258 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5259 * // Immediately 'nuke' the current rows (perhaps waiting for an Ajax callback...)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5260 * oTable.fnClearTable();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5261 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5262 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5263 this.fnClearTable = function( bRedraw )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5264 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5265 /* Find settings from table node */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5266 var oSettings = _fnSettingsFromNode( this[DataTable.ext.iApiIndex] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5267 _fnClearTable( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5268
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5269 if ( bRedraw === undefined || bRedraw )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5270 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5271 _fnDraw( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5272 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5273 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5274
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5275
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5276 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5277 * The exact opposite of 'opening' a row, this function will close any rows which
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5278 * are currently 'open'.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5279 * @param {node} nTr the table row to 'close'
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5280 * @returns {int} 0 on success, or 1 if failed (can't find the row)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5281 * @dtopt API
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5282 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5283 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5284 * $(document).ready(function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5285 * var oTable;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5286 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5287 * // 'open' an information row when a row is clicked on
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5288 * $('#example tbody tr').click( function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5289 * if ( oTable.fnIsOpen(this) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5290 * oTable.fnClose( this );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5291 * } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5292 * oTable.fnOpen( this, "Temporary row opened", "info_row" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5293 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5294 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5295 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5296 * oTable = $('#example').dataTable();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5297 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5298 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5299 this.fnClose = function( nTr )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5300 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5301 /* Find settings from table node */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5302 var oSettings = _fnSettingsFromNode( this[DataTable.ext.iApiIndex] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5303
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5304 for ( var i=0 ; i<oSettings.aoOpenRows.length ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5305 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5306 if ( oSettings.aoOpenRows[i].nParent == nTr )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5307 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5308 var nTrParent = oSettings.aoOpenRows[i].nTr.parentNode;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5309 if ( nTrParent )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5310 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5311 /* Remove it if it is currently on display */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5312 nTrParent.removeChild( oSettings.aoOpenRows[i].nTr );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5313 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5314 oSettings.aoOpenRows.splice( i, 1 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5315 return 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5316 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5317 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5318 return 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5319 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5320
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5321
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5322 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5323 * Remove a row for the table
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5324 * @param {mixed} mTarget The index of the row from aoData to be deleted, or
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5325 * the TR element you want to delete
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5326 * @param {function|null} [fnCallBack] Callback function
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5327 * @param {bool} [bRedraw=true] Redraw the table or not
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5328 * @returns {array} The row that was deleted
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5329 * @dtopt API
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5330 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5331 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5332 * $(document).ready(function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5333 * var oTable = $('#example').dataTable();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5334 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5335 * // Immediately remove the first row
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5336 * oTable.fnDeleteRow( 0 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5337 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5338 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5339 this.fnDeleteRow = function( mTarget, fnCallBack, bRedraw )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5340 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5341 /* Find settings from table node */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5342 var oSettings = _fnSettingsFromNode( this[DataTable.ext.iApiIndex] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5343 var i, iLen, iAODataIndex;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5344
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5345 iAODataIndex = (typeof mTarget === 'object') ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5346 _fnNodeToDataIndex(oSettings, mTarget) : mTarget;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5347
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5348 /* Return the data array from this row */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5349 var oData = oSettings.aoData.splice( iAODataIndex, 1 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5350
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5351 /* Update the _DT_RowIndex parameter */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5352 for ( i=0, iLen=oSettings.aoData.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5353 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5354 if ( oSettings.aoData[i].nTr !== null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5355 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5356 oSettings.aoData[i].nTr._DT_RowIndex = i;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5357 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5358 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5359
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5360 /* Remove the target row from the search array */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5361 var iDisplayIndex = $.inArray( iAODataIndex, oSettings.aiDisplay );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5362 oSettings.asDataSearch.splice( iDisplayIndex, 1 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5363
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5364 /* Delete from the display arrays */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5365 _fnDeleteIndex( oSettings.aiDisplayMaster, iAODataIndex );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5366 _fnDeleteIndex( oSettings.aiDisplay, iAODataIndex );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5367
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5368 /* If there is a user callback function - call it */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5369 if ( typeof fnCallBack === "function" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5370 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5371 fnCallBack.call( this, oSettings, oData );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5372 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5373
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5374 /* Check for an 'overflow' they case for displaying the table */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5375 if ( oSettings._iDisplayStart >= oSettings.fnRecordsDisplay() )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5376 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5377 oSettings._iDisplayStart -= oSettings._iDisplayLength;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5378 if ( oSettings._iDisplayStart < 0 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5379 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5380 oSettings._iDisplayStart = 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5381 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5382 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5383
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5384 if ( bRedraw === undefined || bRedraw )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5385 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5386 _fnCalculateEnd( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5387 _fnDraw( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5388 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5389
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5390 return oData;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5391 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5392
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5393
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5394 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5395 * Restore the table to it's original state in the DOM by removing all of DataTables
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5396 * enhancements, alterations to the DOM structure of the table and event listeners.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5397 * @param {boolean} [bRemove=false] Completely remove the table from the DOM
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5398 * @dtopt API
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5399 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5400 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5401 * $(document).ready(function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5402 * // This example is fairly pointless in reality, but shows how fnDestroy can be used
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5403 * var oTable = $('#example').dataTable();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5404 * oTable.fnDestroy();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5405 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5406 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5407 this.fnDestroy = function ( bRemove )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5408 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5409 var oSettings = _fnSettingsFromNode( this[DataTable.ext.iApiIndex] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5410 var nOrig = oSettings.nTableWrapper.parentNode;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5411 var nBody = oSettings.nTBody;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5412 var i, iLen;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5413
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5414 bRemove = (bRemove===undefined) ? false : bRemove;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5415
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5416 /* Flag to note that the table is currently being destroyed - no action should be taken */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5417 oSettings.bDestroying = true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5418
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5419 /* Fire off the destroy callbacks for plug-ins etc */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5420 _fnCallbackFire( oSettings, "aoDestroyCallback", "destroy", [oSettings] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5421
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5422 /* If the table is not being removed, restore the hidden columns */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5423 if ( !bRemove )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5424 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5425 for ( i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5426 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5427 if ( oSettings.aoColumns[i].bVisible === false )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5428 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5429 this.fnSetColumnVis( i, true );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5430 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5431 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5432 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5433
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5434 /* Blitz all DT events */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5435 $(oSettings.nTableWrapper).find('*').andSelf().unbind('.DT');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5436
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5437 /* If there is an 'empty' indicator row, remove it */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5438 $('tbody>tr>td.'+oSettings.oClasses.sRowEmpty, oSettings.nTable).parent().remove();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5439
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5440 /* When scrolling we had to break the table up - restore it */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5441 if ( oSettings.nTable != oSettings.nTHead.parentNode )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5442 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5443 $(oSettings.nTable).children('thead').remove();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5444 oSettings.nTable.appendChild( oSettings.nTHead );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5445 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5446
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5447 if ( oSettings.nTFoot && oSettings.nTable != oSettings.nTFoot.parentNode )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5448 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5449 $(oSettings.nTable).children('tfoot').remove();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5450 oSettings.nTable.appendChild( oSettings.nTFoot );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5451 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5452
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5453 /* Remove the DataTables generated nodes, events and classes */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5454 oSettings.nTable.parentNode.removeChild( oSettings.nTable );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5455 $(oSettings.nTableWrapper).remove();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5456
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5457 oSettings.aaSorting = [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5458 oSettings.aaSortingFixed = [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5459 _fnSortingClasses( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5460
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5461 $(_fnGetTrNodes( oSettings )).removeClass( oSettings.asStripeClasses.join(' ') );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5462
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5463 $('th, td', oSettings.nTHead).removeClass( [
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5464 oSettings.oClasses.sSortable,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5465 oSettings.oClasses.sSortableAsc,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5466 oSettings.oClasses.sSortableDesc,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5467 oSettings.oClasses.sSortableNone ].join(' ')
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5468 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5469 if ( oSettings.bJUI )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5470 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5471 $('th span.'+oSettings.oClasses.sSortIcon
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5472 + ', td span.'+oSettings.oClasses.sSortIcon, oSettings.nTHead).remove();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5473
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5474 $('th, td', oSettings.nTHead).each( function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5475 var jqWrapper = $('div.'+oSettings.oClasses.sSortJUIWrapper, this);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5476 var kids = jqWrapper.contents();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5477 $(this).append( kids );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5478 jqWrapper.remove();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5479 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5480 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5481
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5482 /* Add the TR elements back into the table in their original order */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5483 if ( !bRemove && oSettings.nTableReinsertBefore )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5484 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5485 nOrig.insertBefore( oSettings.nTable, oSettings.nTableReinsertBefore );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5486 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5487 else if ( !bRemove )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5488 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5489 nOrig.appendChild( oSettings.nTable );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5490 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5491
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5492 for ( i=0, iLen=oSettings.aoData.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5493 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5494 if ( oSettings.aoData[i].nTr !== null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5495 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5496 nBody.appendChild( oSettings.aoData[i].nTr );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5497 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5498 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5499
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5500 /* Restore the width of the original table */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5501 if ( oSettings.oFeatures.bAutoWidth === true )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5502 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5503 oSettings.nTable.style.width = _fnStringToCss(oSettings.sDestroyWidth);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5504 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5505
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5506 /* If the were originally stripe classes - then we add them back here. Note
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5507 * this is not fool proof (for example if not all rows had stripe classes - but
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5508 * it's a good effort without getting carried away
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5509 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5510 iLen = oSettings.asDestroyStripes.length;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5511 if (iLen)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5512 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5513 var anRows = $(nBody).children('tr');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5514 for ( i=0 ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5515 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5516 anRows.filter(':nth-child(' + iLen + 'n + ' + i + ')').addClass( oSettings.asDestroyStripes[i] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5517 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5518 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5519
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5520 /* Remove the settings object from the settings array */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5521 for ( i=0, iLen=DataTable.settings.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5522 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5523 if ( DataTable.settings[i] == oSettings )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5524 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5525 DataTable.settings.splice( i, 1 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5526 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5527 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5528
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5529 /* End it all */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5530 oSettings = null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5531 oInit = null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5532 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5533
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5534
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5535 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5536 * Redraw the table
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5537 * @param {bool} [bComplete=true] Re-filter and resort (if enabled) the table before the draw.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5538 * @dtopt API
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5539 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5540 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5541 * $(document).ready(function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5542 * var oTable = $('#example').dataTable();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5543 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5544 * // Re-draw the table - you wouldn't want to do it here, but it's an example :-)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5545 * oTable.fnDraw();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5546 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5547 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5548 this.fnDraw = function( bComplete )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5549 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5550 var oSettings = _fnSettingsFromNode( this[DataTable.ext.iApiIndex] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5551 if ( bComplete === false )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5552 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5553 _fnCalculateEnd( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5554 _fnDraw( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5555 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5556 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5557 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5558 _fnReDraw( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5559 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5560 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5561
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5562
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5563 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5564 * Filter the input based on data
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5565 * @param {string} sInput String to filter the table on
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5566 * @param {int|null} [iColumn] Column to limit filtering to
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5567 * @param {bool} [bRegex=false] Treat as regular expression or not
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5568 * @param {bool} [bSmart=true] Perform smart filtering or not
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5569 * @param {bool} [bShowGlobal=true] Show the input global filter in it's input box(es)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5570 * @param {bool} [bCaseInsensitive=true] Do case-insensitive matching (true) or not (false)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5571 * @dtopt API
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5572 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5573 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5574 * $(document).ready(function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5575 * var oTable = $('#example').dataTable();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5576 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5577 * // Sometime later - filter...
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5578 * oTable.fnFilter( 'test string' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5579 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5580 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5581 this.fnFilter = function( sInput, iColumn, bRegex, bSmart, bShowGlobal, bCaseInsensitive )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5582 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5583 var oSettings = _fnSettingsFromNode( this[DataTable.ext.iApiIndex] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5584
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5585 if ( !oSettings.oFeatures.bFilter )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5586 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5587 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5588 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5589
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5590 if ( bRegex === undefined || bRegex === null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5591 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5592 bRegex = false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5593 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5594
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5595 if ( bSmart === undefined || bSmart === null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5596 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5597 bSmart = true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5598 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5599
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5600 if ( bShowGlobal === undefined || bShowGlobal === null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5601 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5602 bShowGlobal = true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5603 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5604
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5605 if ( bCaseInsensitive === undefined || bCaseInsensitive === null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5606 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5607 bCaseInsensitive = true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5608 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5609
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5610 if ( iColumn === undefined || iColumn === null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5611 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5612 /* Global filter */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5613 _fnFilterComplete( oSettings, {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5614 "sSearch":sInput+"",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5615 "bRegex": bRegex,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5616 "bSmart": bSmart,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5617 "bCaseInsensitive": bCaseInsensitive
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5618 }, 1 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5619
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5620 if ( bShowGlobal && oSettings.aanFeatures.f )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5621 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5622 var n = oSettings.aanFeatures.f;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5623 for ( var i=0, iLen=n.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5624 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5625 // IE9 throws an 'unknown error' if document.activeElement is used
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5626 // inside an iframe or frame...
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5627 try {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5628 if ( n[i]._DT_Input != document.activeElement )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5629 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5630 $(n[i]._DT_Input).val( sInput );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5631 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5632 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5633 catch ( e ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5634 $(n[i]._DT_Input).val( sInput );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5635 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5636 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5637 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5638 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5639 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5640 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5641 /* Single column filter */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5642 $.extend( oSettings.aoPreSearchCols[ iColumn ], {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5643 "sSearch": sInput+"",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5644 "bRegex": bRegex,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5645 "bSmart": bSmart,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5646 "bCaseInsensitive": bCaseInsensitive
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5647 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5648 _fnFilterComplete( oSettings, oSettings.oPreviousSearch, 1 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5649 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5650 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5651
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5652
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5653 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5654 * Get the data for the whole table, an individual row or an individual cell based on the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5655 * provided parameters.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5656 * @param {int|node} [mRow] A TR row node, TD/TH cell node or an integer. If given as
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5657 * a TR node then the data source for the whole row will be returned. If given as a
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5658 * TD/TH cell node then iCol will be automatically calculated and the data for the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5659 * cell returned. If given as an integer, then this is treated as the aoData internal
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5660 * data index for the row (see fnGetPosition) and the data for that row used.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5661 * @param {int} [iCol] Optional column index that you want the data of.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5662 * @returns {array|object|string} If mRow is undefined, then the data for all rows is
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5663 * returned. If mRow is defined, just data for that row, and is iCol is
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5664 * defined, only data for the designated cell is returned.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5665 * @dtopt API
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5666 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5667 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5668 * // Row data
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5669 * $(document).ready(function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5670 * oTable = $('#example').dataTable();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5671 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5672 * oTable.$('tr').click( function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5673 * var data = oTable.fnGetData( this );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5674 * // ... do something with the array / object of data for the row
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5675 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5676 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5677 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5678 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5679 * // Individual cell data
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5680 * $(document).ready(function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5681 * oTable = $('#example').dataTable();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5682 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5683 * oTable.$('td').click( function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5684 * var sData = oTable.fnGetData( this );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5685 * alert( 'The cell clicked on had the value of '+sData );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5686 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5687 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5688 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5689 this.fnGetData = function( mRow, iCol )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5690 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5691 var oSettings = _fnSettingsFromNode( this[DataTable.ext.iApiIndex] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5692
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5693 if ( mRow !== undefined )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5694 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5695 var iRow = mRow;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5696 if ( typeof mRow === 'object' )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5697 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5698 var sNode = mRow.nodeName.toLowerCase();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5699 if (sNode === "tr" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5700 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5701 iRow = _fnNodeToDataIndex(oSettings, mRow);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5702 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5703 else if ( sNode === "td" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5704 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5705 iRow = _fnNodeToDataIndex(oSettings, mRow.parentNode);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5706 iCol = _fnNodeToColumnIndex( oSettings, iRow, mRow );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5707 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5708 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5709
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5710 if ( iCol !== undefined )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5711 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5712 return _fnGetCellData( oSettings, iRow, iCol, '' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5713 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5714 return (oSettings.aoData[iRow]!==undefined) ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5715 oSettings.aoData[iRow]._aData : null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5716 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5717 return _fnGetDataMaster( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5718 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5719
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5720
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5721 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5722 * Get an array of the TR nodes that are used in the table's body. Note that you will
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5723 * typically want to use the '$' API method in preference to this as it is more
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5724 * flexible.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5725 * @param {int} [iRow] Optional row index for the TR element you want
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5726 * @returns {array|node} If iRow is undefined, returns an array of all TR elements
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5727 * in the table's body, or iRow is defined, just the TR element requested.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5728 * @dtopt API
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5729 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5730 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5731 * $(document).ready(function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5732 * var oTable = $('#example').dataTable();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5733 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5734 * // Get the nodes from the table
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5735 * var nNodes = oTable.fnGetNodes( );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5736 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5737 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5738 this.fnGetNodes = function( iRow )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5739 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5740 var oSettings = _fnSettingsFromNode( this[DataTable.ext.iApiIndex] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5741
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5742 if ( iRow !== undefined ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5743 return (oSettings.aoData[iRow]!==undefined) ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5744 oSettings.aoData[iRow].nTr : null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5745 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5746 return _fnGetTrNodes( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5747 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5748
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5749
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5750 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5751 * Get the array indexes of a particular cell from it's DOM element
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5752 * and column index including hidden columns
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5753 * @param {node} nNode this can either be a TR, TD or TH in the table's body
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5754 * @returns {int} If nNode is given as a TR, then a single index is returned, or
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5755 * if given as a cell, an array of [row index, column index (visible),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5756 * column index (all)] is given.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5757 * @dtopt API
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5758 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5759 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5760 * $(document).ready(function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5761 * $('#example tbody td').click( function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5762 * // Get the position of the current data from the node
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5763 * var aPos = oTable.fnGetPosition( this );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5764 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5765 * // Get the data array for this row
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5766 * var aData = oTable.fnGetData( aPos[0] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5767 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5768 * // Update the data array and return the value
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5769 * aData[ aPos[1] ] = 'clicked';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5770 * this.innerHTML = 'clicked';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5771 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5772 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5773 * // Init DataTables
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5774 * oTable = $('#example').dataTable();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5775 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5776 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5777 this.fnGetPosition = function( nNode )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5778 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5779 var oSettings = _fnSettingsFromNode( this[DataTable.ext.iApiIndex] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5780 var sNodeName = nNode.nodeName.toUpperCase();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5781
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5782 if ( sNodeName == "TR" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5783 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5784 return _fnNodeToDataIndex(oSettings, nNode);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5785 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5786 else if ( sNodeName == "TD" || sNodeName == "TH" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5787 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5788 var iDataIndex = _fnNodeToDataIndex( oSettings, nNode.parentNode );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5789 var iColumnIndex = _fnNodeToColumnIndex( oSettings, iDataIndex, nNode );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5790 return [ iDataIndex, _fnColumnIndexToVisible(oSettings, iColumnIndex ), iColumnIndex ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5791 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5792 return null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5793 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5794
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5795
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5796 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5797 * Check to see if a row is 'open' or not.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5798 * @param {node} nTr the table row to check
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5799 * @returns {boolean} true if the row is currently open, false otherwise
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5800 * @dtopt API
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5801 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5802 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5803 * $(document).ready(function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5804 * var oTable;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5805 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5806 * // 'open' an information row when a row is clicked on
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5807 * $('#example tbody tr').click( function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5808 * if ( oTable.fnIsOpen(this) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5809 * oTable.fnClose( this );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5810 * } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5811 * oTable.fnOpen( this, "Temporary row opened", "info_row" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5812 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5813 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5814 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5815 * oTable = $('#example').dataTable();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5816 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5817 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5818 this.fnIsOpen = function( nTr )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5819 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5820 var oSettings = _fnSettingsFromNode( this[DataTable.ext.iApiIndex] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5821 var aoOpenRows = oSettings.aoOpenRows;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5822
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5823 for ( var i=0 ; i<oSettings.aoOpenRows.length ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5824 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5825 if ( oSettings.aoOpenRows[i].nParent == nTr )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5826 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5827 return true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5828 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5829 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5830 return false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5831 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5832
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5833
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5834 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5835 * This function will place a new row directly after a row which is currently
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5836 * on display on the page, with the HTML contents that is passed into the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5837 * function. This can be used, for example, to ask for confirmation that a
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5838 * particular record should be deleted.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5839 * @param {node} nTr The table row to 'open'
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5840 * @param {string|node|jQuery} mHtml The HTML to put into the row
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5841 * @param {string} sClass Class to give the new TD cell
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5842 * @returns {node} The row opened. Note that if the table row passed in as the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5843 * first parameter, is not found in the table, this method will silently
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5844 * return.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5845 * @dtopt API
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5846 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5847 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5848 * $(document).ready(function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5849 * var oTable;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5850 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5851 * // 'open' an information row when a row is clicked on
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5852 * $('#example tbody tr').click( function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5853 * if ( oTable.fnIsOpen(this) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5854 * oTable.fnClose( this );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5855 * } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5856 * oTable.fnOpen( this, "Temporary row opened", "info_row" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5857 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5858 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5859 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5860 * oTable = $('#example').dataTable();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5861 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5862 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5863 this.fnOpen = function( nTr, mHtml, sClass )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5864 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5865 /* Find settings from table node */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5866 var oSettings = _fnSettingsFromNode( this[DataTable.ext.iApiIndex] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5867
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5868 /* Check that the row given is in the table */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5869 var nTableRows = _fnGetTrNodes( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5870 if ( $.inArray(nTr, nTableRows) === -1 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5871 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5872 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5873 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5874
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5875 /* the old open one if there is one */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5876 this.fnClose( nTr );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5877
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5878 var nNewRow = document.createElement("tr");
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5879 var nNewCell = document.createElement("td");
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5880 nNewRow.appendChild( nNewCell );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5881 nNewCell.className = sClass;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5882 nNewCell.colSpan = _fnVisbleColumns( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5883
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5884 if (typeof mHtml === "string")
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5885 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5886 nNewCell.innerHTML = mHtml;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5887 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5888 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5889 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5890 $(nNewCell).html( mHtml );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5891 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5892
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5893 /* If the nTr isn't on the page at the moment - then we don't insert at the moment */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5894 var nTrs = $('tr', oSettings.nTBody);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5895 if ( $.inArray(nTr, nTrs) != -1 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5896 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5897 $(nNewRow).insertAfter(nTr);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5898 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5899
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5900 oSettings.aoOpenRows.push( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5901 "nTr": nNewRow,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5902 "nParent": nTr
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5903 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5904
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5905 return nNewRow;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5906 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5907
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5908
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5909 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5910 * Change the pagination - provides the internal logic for pagination in a simple API
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5911 * function. With this function you can have a DataTables table go to the next,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5912 * previous, first or last pages.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5913 * @param {string|int} mAction Paging action to take: "first", "previous", "next" or "last"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5914 * or page number to jump to (integer), note that page 0 is the first page.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5915 * @param {bool} [bRedraw=true] Redraw the table or not
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5916 * @dtopt API
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5917 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5918 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5919 * $(document).ready(function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5920 * var oTable = $('#example').dataTable();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5921 * oTable.fnPageChange( 'next' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5922 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5923 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5924 this.fnPageChange = function ( mAction, bRedraw )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5925 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5926 var oSettings = _fnSettingsFromNode( this[DataTable.ext.iApiIndex] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5927 _fnPageChange( oSettings, mAction );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5928 _fnCalculateEnd( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5929
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5930 if ( bRedraw === undefined || bRedraw )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5931 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5932 _fnDraw( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5933 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5934 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5935
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5936
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5937 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5938 * Show a particular column
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5939 * @param {int} iCol The column whose display should be changed
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5940 * @param {bool} bShow Show (true) or hide (false) the column
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5941 * @param {bool} [bRedraw=true] Redraw the table or not
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5942 * @dtopt API
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5943 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5944 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5945 * $(document).ready(function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5946 * var oTable = $('#example').dataTable();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5947 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5948 * // Hide the second column after initialisation
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5949 * oTable.fnSetColumnVis( 1, false );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5950 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5951 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5952 this.fnSetColumnVis = function ( iCol, bShow, bRedraw )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5953 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5954 var oSettings = _fnSettingsFromNode( this[DataTable.ext.iApiIndex] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5955 var i, iLen;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5956 var aoColumns = oSettings.aoColumns;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5957 var aoData = oSettings.aoData;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5958 var nTd, bAppend, iBefore;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5959
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5960 /* No point in doing anything if we are requesting what is already true */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5961 if ( aoColumns[iCol].bVisible == bShow )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5962 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5963 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5964 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5965
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5966 /* Show the column */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5967 if ( bShow )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5968 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5969 var iInsert = 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5970 for ( i=0 ; i<iCol ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5971 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5972 if ( aoColumns[i].bVisible )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5973 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5974 iInsert++;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5975 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5976 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5977
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5978 /* Need to decide if we should use appendChild or insertBefore */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5979 bAppend = (iInsert >= _fnVisbleColumns( oSettings ));
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5980
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5981 /* Which coloumn should we be inserting before? */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5982 if ( !bAppend )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5983 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5984 for ( i=iCol ; i<aoColumns.length ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5985 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5986 if ( aoColumns[i].bVisible )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5987 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5988 iBefore = i;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5989 break;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5990 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5991 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5992 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5993
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5994 for ( i=0, iLen=aoData.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5995 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5996 if ( aoData[i].nTr !== null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5997 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5998 if ( bAppend )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5999 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6000 aoData[i].nTr.appendChild(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6001 aoData[i]._anHidden[iCol]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6002 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6003 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6004 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6005 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6006 aoData[i].nTr.insertBefore(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6007 aoData[i]._anHidden[iCol],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6008 _fnGetTdNodes( oSettings, i )[iBefore] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6009 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6010 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6011 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6012 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6013 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6014 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6015 /* Remove a column from display */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6016 for ( i=0, iLen=aoData.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6017 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6018 if ( aoData[i].nTr !== null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6019 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6020 nTd = _fnGetTdNodes( oSettings, i )[iCol];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6021 aoData[i]._anHidden[iCol] = nTd;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6022 nTd.parentNode.removeChild( nTd );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6023 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6024 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6025 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6026
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6027 /* Clear to set the visible flag */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6028 aoColumns[iCol].bVisible = bShow;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6029
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6030 /* Redraw the header and footer based on the new column visibility */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6031 _fnDrawHead( oSettings, oSettings.aoHeader );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6032 if ( oSettings.nTFoot )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6033 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6034 _fnDrawHead( oSettings, oSettings.aoFooter );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6035 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6036
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6037 /* If there are any 'open' rows, then we need to alter the colspan for this col change */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6038 for ( i=0, iLen=oSettings.aoOpenRows.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6039 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6040 oSettings.aoOpenRows[i].nTr.colSpan = _fnVisbleColumns( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6041 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6042
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6043 /* Do a redraw incase anything depending on the table columns needs it
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6044 * (built-in: scrolling)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6045 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6046 if ( bRedraw === undefined || bRedraw )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6047 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6048 _fnAdjustColumnSizing( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6049 _fnDraw( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6050 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6051
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6052 _fnSaveState( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6053 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6054
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6055
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6056 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6057 * Get the settings for a particular table for external manipulation
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6058 * @returns {object} DataTables settings object. See
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6059 * {@link DataTable.models.oSettings}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6060 * @dtopt API
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6061 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6062 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6063 * $(document).ready(function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6064 * var oTable = $('#example').dataTable();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6065 * var oSettings = oTable.fnSettings();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6066 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6067 * // Show an example parameter from the settings
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6068 * alert( oSettings._iDisplayStart );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6069 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6070 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6071 this.fnSettings = function()
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6072 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6073 return _fnSettingsFromNode( this[DataTable.ext.iApiIndex] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6074 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6075
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6076
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6077 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6078 * Sort the table by a particular column
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6079 * @param {int} iCol the data index to sort on. Note that this will not match the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6080 * 'display index' if you have hidden data entries
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6081 * @dtopt API
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6082 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6083 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6084 * $(document).ready(function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6085 * var oTable = $('#example').dataTable();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6086 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6087 * // Sort immediately with columns 0 and 1
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6088 * oTable.fnSort( [ [0,'asc'], [1,'asc'] ] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6089 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6090 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6091 this.fnSort = function( aaSort )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6092 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6093 var oSettings = _fnSettingsFromNode( this[DataTable.ext.iApiIndex] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6094 oSettings.aaSorting = aaSort;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6095 _fnSort( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6096 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6097
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6098
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6099 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6100 * Attach a sort listener to an element for a given column
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6101 * @param {node} nNode the element to attach the sort listener to
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6102 * @param {int} iColumn the column that a click on this node will sort on
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6103 * @param {function} [fnCallback] callback function when sort is run
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6104 * @dtopt API
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6105 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6106 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6107 * $(document).ready(function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6108 * var oTable = $('#example').dataTable();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6109 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6110 * // Sort on column 1, when 'sorter' is clicked on
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6111 * oTable.fnSortListener( document.getElementById('sorter'), 1 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6112 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6113 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6114 this.fnSortListener = function( nNode, iColumn, fnCallback )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6115 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6116 _fnSortAttachListener( _fnSettingsFromNode( this[DataTable.ext.iApiIndex] ), nNode, iColumn,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6117 fnCallback );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6118 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6119
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6120
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6121 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6122 * Update a table cell or row - this method will accept either a single value to
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6123 * update the cell with, an array of values with one element for each column or
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6124 * an object in the same format as the original data source. The function is
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6125 * self-referencing in order to make the multi column updates easier.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6126 * @param {object|array|string} mData Data to update the cell/row with
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6127 * @param {node|int} mRow TR element you want to update or the aoData index
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6128 * @param {int} [iColumn] The column to update (not used of mData is an array or object)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6129 * @param {bool} [bRedraw=true] Redraw the table or not
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6130 * @param {bool} [bAction=true] Perform pre-draw actions or not
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6131 * @returns {int} 0 on success, 1 on error
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6132 * @dtopt API
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6133 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6134 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6135 * $(document).ready(function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6136 * var oTable = $('#example').dataTable();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6137 * oTable.fnUpdate( 'Example update', 0, 0 ); // Single cell
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6138 * oTable.fnUpdate( ['a', 'b', 'c', 'd', 'e'], 1, 0 ); // Row
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6139 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6140 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6141 this.fnUpdate = function( mData, mRow, iColumn, bRedraw, bAction )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6142 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6143 var oSettings = _fnSettingsFromNode( this[DataTable.ext.iApiIndex] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6144 var i, iLen, sDisplay;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6145 var iRow = (typeof mRow === 'object') ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6146 _fnNodeToDataIndex(oSettings, mRow) : mRow;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6147
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6148 if ( $.isArray(mData) && iColumn === undefined )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6149 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6150 /* Array update - update the whole row */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6151 oSettings.aoData[iRow]._aData = mData.slice();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6152
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6153 /* Flag to the function that we are recursing */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6154 for ( i=0 ; i<oSettings.aoColumns.length ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6155 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6156 this.fnUpdate( _fnGetCellData( oSettings, iRow, i ), iRow, i, false, false );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6157 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6158 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6159 else if ( $.isPlainObject(mData) && iColumn === undefined )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6160 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6161 /* Object update - update the whole row - assume the developer gets the object right */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6162 oSettings.aoData[iRow]._aData = $.extend( true, {}, mData );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6163
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6164 for ( i=0 ; i<oSettings.aoColumns.length ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6165 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6166 this.fnUpdate( _fnGetCellData( oSettings, iRow, i ), iRow, i, false, false );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6167 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6168 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6169 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6170 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6171 /* Individual cell update */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6172 _fnSetCellData( oSettings, iRow, iColumn, mData );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6173 sDisplay = _fnGetCellData( oSettings, iRow, iColumn, 'display' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6174
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6175 var oCol = oSettings.aoColumns[iColumn];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6176 if ( oCol.fnRender !== null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6177 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6178 sDisplay = _fnRender( oSettings, iRow, iColumn );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6179 if ( oCol.bUseRendered )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6180 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6181 _fnSetCellData( oSettings, iRow, iColumn, sDisplay );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6182 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6183 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6184
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6185 if ( oSettings.aoData[iRow].nTr !== null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6186 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6187 /* Do the actual HTML update */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6188 _fnGetTdNodes( oSettings, iRow )[iColumn].innerHTML = sDisplay;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6189 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6190 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6191
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6192 /* Modify the search index for this row (strictly this is likely not needed, since fnReDraw
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6193 * will rebuild the search array - however, the redraw might be disabled by the user)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6194 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6195 var iDisplayIndex = $.inArray( iRow, oSettings.aiDisplay );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6196 oSettings.asDataSearch[iDisplayIndex] = _fnBuildSearchRow(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6197 oSettings,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6198 _fnGetRowData( oSettings, iRow, 'filter', _fnGetColumns( oSettings, 'bSearchable' ) )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6199 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6200
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6201 /* Perform pre-draw actions */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6202 if ( bAction === undefined || bAction )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6203 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6204 _fnAdjustColumnSizing( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6205 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6206
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6207 /* Redraw the table */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6208 if ( bRedraw === undefined || bRedraw )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6209 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6210 _fnReDraw( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6211 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6212 return 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6213 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6214
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6215
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6216 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6217 * Provide a common method for plug-ins to check the version of DataTables being used, in order
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6218 * to ensure compatibility.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6219 * @param {string} sVersion Version string to check for, in the format "X.Y.Z". Note that the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6220 * formats "X" and "X.Y" are also acceptable.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6221 * @returns {boolean} true if this version of DataTables is greater or equal to the required
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6222 * version, or false if this version of DataTales is not suitable
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6223 * @method
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6224 * @dtopt API
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6225 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6226 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6227 * $(document).ready(function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6228 * var oTable = $('#example').dataTable();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6229 * alert( oTable.fnVersionCheck( '1.9.0' ) );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6230 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6231 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6232 this.fnVersionCheck = DataTable.ext.fnVersionCheck;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6233
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6234
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6235 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6236 * This is really a good bit rubbish this method of exposing the internal methods
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6237 * publicly... - To be fixed in 2.0 using methods on the prototype
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6238 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6239
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6240
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6241 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6242 * Create a wrapper function for exporting an internal functions to an external API.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6243 * @param {string} sFunc API function name
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6244 * @returns {function} wrapped function
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6245 * @memberof DataTable#oApi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6246 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6247 function _fnExternApiFunc (sFunc)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6248 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6249 return function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6250 var aArgs = [_fnSettingsFromNode(this[DataTable.ext.iApiIndex])].concat(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6251 Array.prototype.slice.call(arguments) );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6252 return DataTable.ext.oApi[sFunc].apply( this, aArgs );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6253 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6254 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6255
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6256
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6257 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6258 * Reference to internal functions for use by plug-in developers. Note that these
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6259 * methods are references to internal functions and are considered to be private.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6260 * If you use these methods, be aware that they are liable to change between versions
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6261 * (check the upgrade notes).
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6262 * @namespace
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6263 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6264 this.oApi = {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6265 "_fnExternApiFunc": _fnExternApiFunc,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6266 "_fnInitialise": _fnInitialise,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6267 "_fnInitComplete": _fnInitComplete,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6268 "_fnLanguageCompat": _fnLanguageCompat,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6269 "_fnAddColumn": _fnAddColumn,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6270 "_fnColumnOptions": _fnColumnOptions,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6271 "_fnAddData": _fnAddData,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6272 "_fnCreateTr": _fnCreateTr,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6273 "_fnGatherData": _fnGatherData,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6274 "_fnBuildHead": _fnBuildHead,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6275 "_fnDrawHead": _fnDrawHead,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6276 "_fnDraw": _fnDraw,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6277 "_fnReDraw": _fnReDraw,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6278 "_fnAjaxUpdate": _fnAjaxUpdate,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6279 "_fnAjaxParameters": _fnAjaxParameters,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6280 "_fnAjaxUpdateDraw": _fnAjaxUpdateDraw,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6281 "_fnServerParams": _fnServerParams,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6282 "_fnAddOptionsHtml": _fnAddOptionsHtml,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6283 "_fnFeatureHtmlTable": _fnFeatureHtmlTable,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6284 "_fnScrollDraw": _fnScrollDraw,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6285 "_fnAdjustColumnSizing": _fnAdjustColumnSizing,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6286 "_fnFeatureHtmlFilter": _fnFeatureHtmlFilter,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6287 "_fnFilterComplete": _fnFilterComplete,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6288 "_fnFilterCustom": _fnFilterCustom,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6289 "_fnFilterColumn": _fnFilterColumn,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6290 "_fnFilter": _fnFilter,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6291 "_fnBuildSearchArray": _fnBuildSearchArray,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6292 "_fnBuildSearchRow": _fnBuildSearchRow,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6293 "_fnFilterCreateSearch": _fnFilterCreateSearch,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6294 "_fnDataToSearch": _fnDataToSearch,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6295 "_fnSort": _fnSort,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6296 "_fnSortAttachListener": _fnSortAttachListener,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6297 "_fnSortingClasses": _fnSortingClasses,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6298 "_fnFeatureHtmlPaginate": _fnFeatureHtmlPaginate,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6299 "_fnPageChange": _fnPageChange,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6300 "_fnFeatureHtmlInfo": _fnFeatureHtmlInfo,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6301 "_fnUpdateInfo": _fnUpdateInfo,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6302 "_fnFeatureHtmlLength": _fnFeatureHtmlLength,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6303 "_fnFeatureHtmlProcessing": _fnFeatureHtmlProcessing,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6304 "_fnProcessingDisplay": _fnProcessingDisplay,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6305 "_fnVisibleToColumnIndex": _fnVisibleToColumnIndex,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6306 "_fnColumnIndexToVisible": _fnColumnIndexToVisible,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6307 "_fnNodeToDataIndex": _fnNodeToDataIndex,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6308 "_fnVisbleColumns": _fnVisbleColumns,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6309 "_fnCalculateEnd": _fnCalculateEnd,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6310 "_fnConvertToWidth": _fnConvertToWidth,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6311 "_fnCalculateColumnWidths": _fnCalculateColumnWidths,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6312 "_fnScrollingWidthAdjust": _fnScrollingWidthAdjust,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6313 "_fnGetWidestNode": _fnGetWidestNode,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6314 "_fnGetMaxLenString": _fnGetMaxLenString,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6315 "_fnStringToCss": _fnStringToCss,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6316 "_fnDetectType": _fnDetectType,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6317 "_fnSettingsFromNode": _fnSettingsFromNode,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6318 "_fnGetDataMaster": _fnGetDataMaster,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6319 "_fnGetTrNodes": _fnGetTrNodes,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6320 "_fnGetTdNodes": _fnGetTdNodes,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6321 "_fnEscapeRegex": _fnEscapeRegex,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6322 "_fnDeleteIndex": _fnDeleteIndex,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6323 "_fnReOrderIndex": _fnReOrderIndex,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6324 "_fnColumnOrdering": _fnColumnOrdering,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6325 "_fnLog": _fnLog,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6326 "_fnClearTable": _fnClearTable,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6327 "_fnSaveState": _fnSaveState,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6328 "_fnLoadState": _fnLoadState,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6329 "_fnCreateCookie": _fnCreateCookie,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6330 "_fnReadCookie": _fnReadCookie,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6331 "_fnDetectHeader": _fnDetectHeader,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6332 "_fnGetUniqueThs": _fnGetUniqueThs,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6333 "_fnScrollBarWidth": _fnScrollBarWidth,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6334 "_fnApplyToChildren": _fnApplyToChildren,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6335 "_fnMap": _fnMap,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6336 "_fnGetRowData": _fnGetRowData,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6337 "_fnGetCellData": _fnGetCellData,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6338 "_fnSetCellData": _fnSetCellData,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6339 "_fnGetObjectDataFn": _fnGetObjectDataFn,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6340 "_fnSetObjectDataFn": _fnSetObjectDataFn,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6341 "_fnApplyColumnDefs": _fnApplyColumnDefs,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6342 "_fnBindAction": _fnBindAction,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6343 "_fnExtend": _fnExtend,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6344 "_fnCallbackReg": _fnCallbackReg,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6345 "_fnCallbackFire": _fnCallbackFire,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6346 "_fnJsonString": _fnJsonString,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6347 "_fnRender": _fnRender,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6348 "_fnNodeToColumnIndex": _fnNodeToColumnIndex,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6349 "_fnInfoMacros": _fnInfoMacros,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6350 "_fnBrowserDetect": _fnBrowserDetect,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6351 "_fnGetColumns": _fnGetColumns
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6352 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6353
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6354 $.extend( DataTable.ext.oApi, this.oApi );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6355
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6356 for ( var sFunc in DataTable.ext.oApi )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6357 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6358 if ( sFunc )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6359 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6360 this[sFunc] = _fnExternApiFunc(sFunc);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6361 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6362 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6363
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6364
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6365 var _that = this;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6366 this.each(function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6367 var i=0, iLen, j, jLen, k, kLen;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6368 var sId = this.getAttribute( 'id' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6369 var bInitHandedOff = false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6370 var bUsePassedData = false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6371
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6372
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6373 /* Sanity check */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6374 if ( this.nodeName.toLowerCase() != 'table' )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6375 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6376 _fnLog( null, 0, "Attempted to initialise DataTables on a node which is not a "+
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6377 "table: "+this.nodeName );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6378 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6379 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6380
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6381 /* Check to see if we are re-initialising a table */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6382 for ( i=0, iLen=DataTable.settings.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6383 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6384 /* Base check on table node */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6385 if ( DataTable.settings[i].nTable == this )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6386 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6387 if ( oInit === undefined || oInit.bRetrieve )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6388 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6389 return DataTable.settings[i].oInstance;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6390 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6391 else if ( oInit.bDestroy )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6392 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6393 DataTable.settings[i].oInstance.fnDestroy();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6394 break;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6395 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6396 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6397 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6398 _fnLog( DataTable.settings[i], 0, "Cannot reinitialise DataTable.\n\n"+
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6399 "To retrieve the DataTables object for this table, pass no arguments or see "+
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6400 "the docs for bRetrieve and bDestroy" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6401 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6402 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6403 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6404
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6405 /* If the element we are initialising has the same ID as a table which was previously
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6406 * initialised, but the table nodes don't match (from before) then we destroy the old
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6407 * instance by simply deleting it. This is under the assumption that the table has been
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6408 * destroyed by other methods. Anyone using non-id selectors will need to do this manually
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6409 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6410 if ( DataTable.settings[i].sTableId == this.id )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6411 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6412 DataTable.settings.splice( i, 1 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6413 break;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6414 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6415 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6416
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6417 /* Ensure the table has an ID - required for accessibility */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6418 if ( sId === null || sId === "" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6419 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6420 sId = "DataTables_Table_"+(DataTable.ext._oExternConfig.iNextUnique++);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6421 this.id = sId;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6422 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6423
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6424 /* Create the settings object for this table and set some of the default parameters */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6425 var oSettings = $.extend( true, {}, DataTable.models.oSettings, {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6426 "nTable": this,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6427 "oApi": _that.oApi,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6428 "oInit": oInit,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6429 "sDestroyWidth": $(this).width(),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6430 "sInstance": sId,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6431 "sTableId": sId
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6432 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6433 DataTable.settings.push( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6434
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6435 // Need to add the instance after the instance after the settings object has been added
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6436 // to the settings array, so we can self reference the table instance if more than one
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6437 oSettings.oInstance = (_that.length===1) ? _that : $(this).dataTable();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6438
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6439 /* Setting up the initialisation object */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6440 if ( !oInit )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6441 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6442 oInit = {};
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6443 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6444
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6445 // Backwards compatibility, before we apply all the defaults
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6446 if ( oInit.oLanguage )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6447 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6448 _fnLanguageCompat( oInit.oLanguage );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6449 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6450
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6451 oInit = _fnExtend( $.extend(true, {}, DataTable.defaults), oInit );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6452
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6453 // Map the initialisation options onto the settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6454 _fnMap( oSettings.oFeatures, oInit, "bPaginate" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6455 _fnMap( oSettings.oFeatures, oInit, "bLengthChange" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6456 _fnMap( oSettings.oFeatures, oInit, "bFilter" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6457 _fnMap( oSettings.oFeatures, oInit, "bSort" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6458 _fnMap( oSettings.oFeatures, oInit, "bInfo" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6459 _fnMap( oSettings.oFeatures, oInit, "bProcessing" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6460 _fnMap( oSettings.oFeatures, oInit, "bAutoWidth" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6461 _fnMap( oSettings.oFeatures, oInit, "bSortClasses" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6462 _fnMap( oSettings.oFeatures, oInit, "bServerSide" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6463 _fnMap( oSettings.oFeatures, oInit, "bDeferRender" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6464 _fnMap( oSettings.oScroll, oInit, "sScrollX", "sX" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6465 _fnMap( oSettings.oScroll, oInit, "sScrollXInner", "sXInner" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6466 _fnMap( oSettings.oScroll, oInit, "sScrollY", "sY" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6467 _fnMap( oSettings.oScroll, oInit, "bScrollCollapse", "bCollapse" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6468 _fnMap( oSettings.oScroll, oInit, "bScrollInfinite", "bInfinite" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6469 _fnMap( oSettings.oScroll, oInit, "iScrollLoadGap", "iLoadGap" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6470 _fnMap( oSettings.oScroll, oInit, "bScrollAutoCss", "bAutoCss" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6471 _fnMap( oSettings, oInit, "asStripeClasses" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6472 _fnMap( oSettings, oInit, "asStripClasses", "asStripeClasses" ); // legacy
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6473 _fnMap( oSettings, oInit, "fnServerData" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6474 _fnMap( oSettings, oInit, "fnFormatNumber" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6475 _fnMap( oSettings, oInit, "sServerMethod" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6476 _fnMap( oSettings, oInit, "aaSorting" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6477 _fnMap( oSettings, oInit, "aaSortingFixed" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6478 _fnMap( oSettings, oInit, "aLengthMenu" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6479 _fnMap( oSettings, oInit, "sPaginationType" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6480 _fnMap( oSettings, oInit, "sAjaxSource" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6481 _fnMap( oSettings, oInit, "sAjaxDataProp" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6482 _fnMap( oSettings, oInit, "iCookieDuration" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6483 _fnMap( oSettings, oInit, "sCookiePrefix" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6484 _fnMap( oSettings, oInit, "sDom" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6485 _fnMap( oSettings, oInit, "bSortCellsTop" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6486 _fnMap( oSettings, oInit, "iTabIndex" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6487 _fnMap( oSettings, oInit, "oSearch", "oPreviousSearch" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6488 _fnMap( oSettings, oInit, "aoSearchCols", "aoPreSearchCols" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6489 _fnMap( oSettings, oInit, "iDisplayLength", "_iDisplayLength" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6490 _fnMap( oSettings, oInit, "bJQueryUI", "bJUI" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6491 _fnMap( oSettings, oInit, "fnCookieCallback" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6492 _fnMap( oSettings, oInit, "fnStateLoad" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6493 _fnMap( oSettings, oInit, "fnStateSave" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6494 _fnMap( oSettings.oLanguage, oInit, "fnInfoCallback" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6495
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6496 /* Callback functions which are array driven */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6497 _fnCallbackReg( oSettings, 'aoDrawCallback', oInit.fnDrawCallback, 'user' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6498 _fnCallbackReg( oSettings, 'aoServerParams', oInit.fnServerParams, 'user' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6499 _fnCallbackReg( oSettings, 'aoStateSaveParams', oInit.fnStateSaveParams, 'user' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6500 _fnCallbackReg( oSettings, 'aoStateLoadParams', oInit.fnStateLoadParams, 'user' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6501 _fnCallbackReg( oSettings, 'aoStateLoaded', oInit.fnStateLoaded, 'user' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6502 _fnCallbackReg( oSettings, 'aoRowCallback', oInit.fnRowCallback, 'user' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6503 _fnCallbackReg( oSettings, 'aoRowCreatedCallback', oInit.fnCreatedRow, 'user' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6504 _fnCallbackReg( oSettings, 'aoHeaderCallback', oInit.fnHeaderCallback, 'user' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6505 _fnCallbackReg( oSettings, 'aoFooterCallback', oInit.fnFooterCallback, 'user' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6506 _fnCallbackReg( oSettings, 'aoInitComplete', oInit.fnInitComplete, 'user' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6507 _fnCallbackReg( oSettings, 'aoPreDrawCallback', oInit.fnPreDrawCallback, 'user' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6508
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6509 if ( oSettings.oFeatures.bServerSide && oSettings.oFeatures.bSort &&
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6510 oSettings.oFeatures.bSortClasses )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6511 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6512 /* Enable sort classes for server-side processing. Safe to do it here, since server-side
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6513 * processing must be enabled by the developer
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6514 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6515 _fnCallbackReg( oSettings, 'aoDrawCallback', _fnSortingClasses, 'server_side_sort_classes' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6516 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6517 else if ( oSettings.oFeatures.bDeferRender )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6518 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6519 _fnCallbackReg( oSettings, 'aoDrawCallback', _fnSortingClasses, 'defer_sort_classes' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6520 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6521
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6522 if ( oInit.bJQueryUI )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6523 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6524 /* Use the JUI classes object for display. You could clone the oStdClasses object if
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6525 * you want to have multiple tables with multiple independent classes
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6526 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6527 $.extend( oSettings.oClasses, DataTable.ext.oJUIClasses );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6528
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6529 if ( oInit.sDom === DataTable.defaults.sDom && DataTable.defaults.sDom === "lfrtip" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6530 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6531 /* Set the DOM to use a layout suitable for jQuery UI's theming */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6532 oSettings.sDom = '<"H"lfr>t<"F"ip>';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6533 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6534 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6535 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6536 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6537 $.extend( oSettings.oClasses, DataTable.ext.oStdClasses );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6538 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6539 $(this).addClass( oSettings.oClasses.sTable );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6540
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6541 /* Calculate the scroll bar width and cache it for use later on */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6542 if ( oSettings.oScroll.sX !== "" || oSettings.oScroll.sY !== "" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6543 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6544 oSettings.oScroll.iBarWidth = _fnScrollBarWidth();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6545 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6546
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6547 if ( oSettings.iInitDisplayStart === undefined )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6548 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6549 /* Display start point, taking into account the save saving */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6550 oSettings.iInitDisplayStart = oInit.iDisplayStart;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6551 oSettings._iDisplayStart = oInit.iDisplayStart;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6552 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6553
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6554 /* Must be done after everything which can be overridden by a cookie! */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6555 if ( oInit.bStateSave )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6556 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6557 oSettings.oFeatures.bStateSave = true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6558 _fnLoadState( oSettings, oInit );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6559 _fnCallbackReg( oSettings, 'aoDrawCallback', _fnSaveState, 'state_save' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6560 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6561
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6562 if ( oInit.iDeferLoading !== null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6563 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6564 oSettings.bDeferLoading = true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6565 var tmp = $.isArray( oInit.iDeferLoading );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6566 oSettings._iRecordsDisplay = tmp ? oInit.iDeferLoading[0] : oInit.iDeferLoading;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6567 oSettings._iRecordsTotal = tmp ? oInit.iDeferLoading[1] : oInit.iDeferLoading;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6568 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6569
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6570 if ( oInit.aaData !== null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6571 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6572 bUsePassedData = true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6573 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6574
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6575 /* Language definitions */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6576 if ( oInit.oLanguage.sUrl !== "" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6577 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6578 /* Get the language definitions from a file - because this Ajax call makes the language
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6579 * get async to the remainder of this function we use bInitHandedOff to indicate that
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6580 * _fnInitialise will be fired by the returned Ajax handler, rather than the constructor
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6581 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6582 oSettings.oLanguage.sUrl = oInit.oLanguage.sUrl;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6583 $.getJSON( oSettings.oLanguage.sUrl, null, function( json ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6584 _fnLanguageCompat( json );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6585 $.extend( true, oSettings.oLanguage, oInit.oLanguage, json );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6586 _fnInitialise( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6587 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6588 bInitHandedOff = true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6589 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6590 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6591 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6592 $.extend( true, oSettings.oLanguage, oInit.oLanguage );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6593 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6594
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6595
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6596 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6597 * Stripes
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6598 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6599 if ( oInit.asStripeClasses === null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6600 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6601 oSettings.asStripeClasses =[
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6602 oSettings.oClasses.sStripeOdd,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6603 oSettings.oClasses.sStripeEven
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6604 ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6605 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6606
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6607 /* Remove row stripe classes if they are already on the table row */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6608 iLen=oSettings.asStripeClasses.length;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6609 oSettings.asDestroyStripes = [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6610 if (iLen)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6611 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6612 var bStripeRemove = false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6613 var anRows = $(this).children('tbody').children('tr:lt(' + iLen + ')');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6614 for ( i=0 ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6615 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6616 if ( anRows.hasClass( oSettings.asStripeClasses[i] ) )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6617 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6618 bStripeRemove = true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6619
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6620 /* Store the classes which we are about to remove so they can be re-added on destroy */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6621 oSettings.asDestroyStripes.push( oSettings.asStripeClasses[i] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6622 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6623 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6624
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6625 if ( bStripeRemove )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6626 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6627 anRows.removeClass( oSettings.asStripeClasses.join(' ') );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6628 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6629 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6630
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6631 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6632 * Columns
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6633 * See if we should load columns automatically or use defined ones
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6634 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6635 var anThs = [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6636 var aoColumnsInit;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6637 var nThead = this.getElementsByTagName('thead');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6638 if ( nThead.length !== 0 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6639 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6640 _fnDetectHeader( oSettings.aoHeader, nThead[0] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6641 anThs = _fnGetUniqueThs( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6642 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6643
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6644 /* If not given a column array, generate one with nulls */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6645 if ( oInit.aoColumns === null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6646 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6647 aoColumnsInit = [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6648 for ( i=0, iLen=anThs.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6649 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6650 aoColumnsInit.push( null );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6651 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6652 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6653 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6654 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6655 aoColumnsInit = oInit.aoColumns;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6656 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6657
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6658 /* Add the columns */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6659 for ( i=0, iLen=aoColumnsInit.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6660 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6661 /* Short cut - use the loop to check if we have column visibility state to restore */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6662 if ( oInit.saved_aoColumns !== undefined && oInit.saved_aoColumns.length == iLen )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6663 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6664 if ( aoColumnsInit[i] === null )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6665 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6666 aoColumnsInit[i] = {};
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6667 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6668 aoColumnsInit[i].bVisible = oInit.saved_aoColumns[i].bVisible;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6669 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6670
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6671 _fnAddColumn( oSettings, anThs ? anThs[i] : null );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6672 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6673
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6674 /* Apply the column definitions */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6675 _fnApplyColumnDefs( oSettings, oInit.aoColumnDefs, aoColumnsInit, function (iCol, oDef) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6676 _fnColumnOptions( oSettings, iCol, oDef );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6677 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6678
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6679
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6680 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6681 * Sorting
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6682 * Check the aaSorting array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6683 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6684 for ( i=0, iLen=oSettings.aaSorting.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6685 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6686 if ( oSettings.aaSorting[i][0] >= oSettings.aoColumns.length )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6687 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6688 oSettings.aaSorting[i][0] = 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6689 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6690 var oColumn = oSettings.aoColumns[ oSettings.aaSorting[i][0] ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6691
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6692 /* Add a default sorting index */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6693 if ( oSettings.aaSorting[i][2] === undefined )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6694 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6695 oSettings.aaSorting[i][2] = 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6696 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6697
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6698 /* If aaSorting is not defined, then we use the first indicator in asSorting */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6699 if ( oInit.aaSorting === undefined && oSettings.saved_aaSorting === undefined )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6700 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6701 oSettings.aaSorting[i][1] = oColumn.asSorting[0];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6702 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6703
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6704 /* Set the current sorting index based on aoColumns.asSorting */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6705 for ( j=0, jLen=oColumn.asSorting.length ; j<jLen ; j++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6706 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6707 if ( oSettings.aaSorting[i][1] == oColumn.asSorting[j] )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6708 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6709 oSettings.aaSorting[i][2] = j;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6710 break;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6711 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6712 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6713 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6714
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6715 /* Do a first pass on the sorting classes (allows any size changes to be taken into
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6716 * account, and also will apply sorting disabled classes if disabled
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6717 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6718 _fnSortingClasses( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6719
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6720
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6721 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6722 * Final init
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6723 * Cache the header, body and footer as required, creating them if needed
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6724 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6725
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6726 /* Browser support detection */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6727 _fnBrowserDetect( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6728
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6729 // Work around for Webkit bug 83867 - store the caption-side before removing from doc
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6730 var captions = $(this).children('caption').each( function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6731 this._captionSide = $(this).css('caption-side');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6732 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6733
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6734 var thead = $(this).children('thead');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6735 if ( thead.length === 0 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6736 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6737 thead = [ document.createElement( 'thead' ) ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6738 this.appendChild( thead[0] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6739 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6740 oSettings.nTHead = thead[0];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6741
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6742 var tbody = $(this).children('tbody');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6743 if ( tbody.length === 0 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6744 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6745 tbody = [ document.createElement( 'tbody' ) ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6746 this.appendChild( tbody[0] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6747 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6748 oSettings.nTBody = tbody[0];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6749 oSettings.nTBody.setAttribute( "role", "alert" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6750 oSettings.nTBody.setAttribute( "aria-live", "polite" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6751 oSettings.nTBody.setAttribute( "aria-relevant", "all" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6752
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6753 var tfoot = $(this).children('tfoot');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6754 if ( tfoot.length === 0 && captions.length > 0 && (oSettings.oScroll.sX !== "" || oSettings.oScroll.sY !== "") )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6755 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6756 // If we are a scrolling table, and no footer has been given, then we need to create
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6757 // a tfoot element for the caption element to be appended to
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6758 tfoot = [ document.createElement( 'tfoot' ) ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6759 this.appendChild( tfoot[0] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6760 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6761
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6762 if ( tfoot.length > 0 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6763 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6764 oSettings.nTFoot = tfoot[0];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6765 _fnDetectHeader( oSettings.aoFooter, oSettings.nTFoot );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6766 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6767
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6768 /* Check if there is data passing into the constructor */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6769 if ( bUsePassedData )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6770 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6771 for ( i=0 ; i<oInit.aaData.length ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6772 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6773 _fnAddData( oSettings, oInit.aaData[ i ] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6774 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6775 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6776 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6777 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6778 /* Grab the data from the page */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6779 _fnGatherData( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6780 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6781
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6782 /* Copy the data index array */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6783 oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6784
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6785 /* Initialisation complete - table can be drawn */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6786 oSettings.bInitialised = true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6787
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6788 /* Check if we need to initialise the table (it might not have been handed off to the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6789 * language processor)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6790 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6791 if ( bInitHandedOff === false )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6792 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6793 _fnInitialise( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6794 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6795 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6796 _that = null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6797 return this;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6798 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6799
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6800
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6801
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6802 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6803 * Provide a common method for plug-ins to check the version of DataTables being used, in order
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6804 * to ensure compatibility.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6805 * @param {string} sVersion Version string to check for, in the format "X.Y.Z". Note that the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6806 * formats "X" and "X.Y" are also acceptable.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6807 * @returns {boolean} true if this version of DataTables is greater or equal to the required
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6808 * version, or false if this version of DataTales is not suitable
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6809 * @static
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6810 * @dtopt API-Static
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6811 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6812 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6813 * alert( $.fn.dataTable.fnVersionCheck( '1.9.0' ) );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6814 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6815 DataTable.fnVersionCheck = function( sVersion )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6816 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6817 /* This is cheap, but effective */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6818 var fnZPad = function (Zpad, count)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6819 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6820 while(Zpad.length < count) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6821 Zpad += '0';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6822 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6823 return Zpad;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6824 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6825 var aThis = DataTable.ext.sVersion.split('.');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6826 var aThat = sVersion.split('.');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6827 var sThis = '', sThat = '';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6828
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6829 for ( var i=0, iLen=aThat.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6830 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6831 sThis += fnZPad( aThis[i], 3 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6832 sThat += fnZPad( aThat[i], 3 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6833 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6834
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6835 return parseInt(sThis, 10) >= parseInt(sThat, 10);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6836 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6837
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6838
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6839 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6840 * Check if a TABLE node is a DataTable table already or not.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6841 * @param {node} nTable The TABLE node to check if it is a DataTable or not (note that other
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6842 * node types can be passed in, but will always return false).
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6843 * @returns {boolean} true the table given is a DataTable, or false otherwise
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6844 * @static
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6845 * @dtopt API-Static
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6846 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6847 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6848 * var ex = document.getElementById('example');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6849 * if ( ! $.fn.DataTable.fnIsDataTable( ex ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6850 * $(ex).dataTable();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6851 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6852 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6853 DataTable.fnIsDataTable = function ( nTable )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6854 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6855 var o = DataTable.settings;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6856
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6857 for ( var i=0 ; i<o.length ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6858 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6859 if ( o[i].nTable === nTable || o[i].nScrollHead === nTable || o[i].nScrollFoot === nTable )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6860 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6861 return true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6862 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6863 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6864
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6865 return false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6866 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6867
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6868
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6869 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6870 * Get all DataTable tables that have been initialised - optionally you can select to
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6871 * get only currently visible tables.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6872 * @param {boolean} [bVisible=false] Flag to indicate if you want all (default) or
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6873 * visible tables only.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6874 * @returns {array} Array of TABLE nodes (not DataTable instances) which are DataTables
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6875 * @static
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6876 * @dtopt API-Static
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6877 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6878 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6879 * var table = $.fn.dataTable.fnTables(true);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6880 * if ( table.length > 0 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6881 * $(table).dataTable().fnAdjustColumnSizing();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6882 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6883 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6884 DataTable.fnTables = function ( bVisible )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6885 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6886 var out = [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6887
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6888 jQuery.each( DataTable.settings, function (i, o) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6889 if ( !bVisible || (bVisible === true && $(o.nTable).is(':visible')) )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6890 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6891 out.push( o.nTable );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6892 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6893 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6894
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6895 return out;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6896 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6897
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6898
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6899 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6900 * Version string for plug-ins to check compatibility. Allowed format is
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6901 * a.b.c.d.e where: a:int, b:int, c:int, d:string(dev|beta), e:int. d and
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6902 * e are optional
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6903 * @member
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6904 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6905 * @default Version number
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6906 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6907 DataTable.version = "1.9.4";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6908
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6909 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6910 * Private data store, containing all of the settings objects that are created for the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6911 * tables on a given page.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6912 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6913 * Note that the <i>DataTable.settings</i> object is aliased to <i>jQuery.fn.dataTableExt</i>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6914 * through which it may be accessed and manipulated, or <i>jQuery.fn.dataTable.settings</i>.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6915 * @member
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6916 * @type array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6917 * @default []
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6918 * @private
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6919 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6920 DataTable.settings = [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6921
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6922 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6923 * Object models container, for the various models that DataTables has available
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6924 * to it. These models define the objects that are used to hold the active state
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6925 * and configuration of the table.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6926 * @namespace
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6927 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6928 DataTable.models = {};
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6929
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6930
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6931 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6932 * DataTables extension options and plug-ins. This namespace acts as a collection "area"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6933 * for plug-ins that can be used to extend the default DataTables behaviour - indeed many
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6934 * of the build in methods use this method to provide their own capabilities (sorting methods
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6935 * for example).
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6936 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6937 * Note that this namespace is aliased to jQuery.fn.dataTableExt so it can be readily accessed
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6938 * and modified by plug-ins.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6939 * @namespace
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6940 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6941 DataTable.models.ext = {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6942 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6943 * Plug-in filtering functions - this method of filtering is complimentary to the default
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6944 * type based filtering, and a lot more comprehensive as it allows you complete control
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6945 * over the filtering logic. Each element in this array is a function (parameters
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6946 * described below) that is called for every row in the table, and your logic decides if
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6947 * it should be included in the filtered data set or not.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6948 * <ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6949 * <li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6950 * Function input parameters:
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6951 * <ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6952 * <li>{object} DataTables settings object: see {@link DataTable.models.oSettings}.</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6953 * <li>{array|object} Data for the row to be processed (same as the original format
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6954 * that was passed in as the data source, or an array from a DOM data source</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6955 * <li>{int} Row index in aoData ({@link DataTable.models.oSettings.aoData}), which can
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6956 * be useful to retrieve the TR element if you need DOM interaction.</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6957 * </ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6958 * </li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6959 * <li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6960 * Function return:
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6961 * <ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6962 * <li>{boolean} Include the row in the filtered result set (true) or not (false)</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6963 * </ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6964 * </il>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6965 * </ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6966 * @type array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6967 * @default []
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6968 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6969 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6970 * // The following example shows custom filtering being applied to the fourth column (i.e.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6971 * // the aData[3] index) based on two input values from the end-user, matching the data in
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6972 * // a certain range.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6973 * $.fn.dataTableExt.afnFiltering.push(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6974 * function( oSettings, aData, iDataIndex ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6975 * var iMin = document.getElementById('min').value * 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6976 * var iMax = document.getElementById('max').value * 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6977 * var iVersion = aData[3] == "-" ? 0 : aData[3]*1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6978 * if ( iMin == "" && iMax == "" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6979 * return true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6980 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6981 * else if ( iMin == "" && iVersion < iMax ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6982 * return true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6983 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6984 * else if ( iMin < iVersion && "" == iMax ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6985 * return true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6986 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6987 * else if ( iMin < iVersion && iVersion < iMax ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6988 * return true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6989 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6990 * return false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6991 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6992 * );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6993 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6994 "afnFiltering": [],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6995
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6996
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6997 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6998 * Plug-in sorting functions - this method of sorting is complimentary to the default type
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6999 * based sorting that DataTables does automatically, allowing much greater control over the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7000 * the data that is being used to sort a column. This is useful if you want to do sorting
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7001 * based on live data (for example the contents of an 'input' element) rather than just the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7002 * static string that DataTables knows of. The way these plug-ins work is that you create
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7003 * an array of the values you wish to be sorted for the column in question and then return
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7004 * that array. Which pre-sorting function is run here depends on the sSortDataType parameter
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7005 * that is used for the column (if any). This is the corollary of <i>ofnSearch</i> for sort
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7006 * data.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7007 * <ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7008 * <li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7009 * Function input parameters:
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7010 * <ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7011 * <li>{object} DataTables settings object: see {@link DataTable.models.oSettings}.</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7012 * <li>{int} Target column index</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7013 * </ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7014 * </li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7015 * <li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7016 * Function return:
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7017 * <ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7018 * <li>{array} Data for the column to be sorted upon</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7019 * </ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7020 * </il>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7021 * </ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7022 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7023 * Note that as of v1.9, it is typically preferable to use <i>mData</i> to prepare data for
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7024 * the different uses that DataTables can put the data to. Specifically <i>mData</i> when
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7025 * used as a function will give you a 'type' (sorting, filtering etc) that you can use to
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7026 * prepare the data as required for the different types. As such, this method is deprecated.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7027 * @type array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7028 * @default []
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7029 * @deprecated
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7030 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7031 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7032 * // Updating the cached sorting information with user entered values in HTML input elements
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7033 * jQuery.fn.dataTableExt.afnSortData['dom-text'] = function ( oSettings, iColumn )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7034 * {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7035 * var aData = [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7036 * $( 'td:eq('+iColumn+') input', oSettings.oApi._fnGetTrNodes(oSettings) ).each( function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7037 * aData.push( this.value );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7038 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7039 * return aData;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7040 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7041 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7042 "afnSortData": [],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7043
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7044
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7045 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7046 * Feature plug-ins - This is an array of objects which describe the feature plug-ins that are
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7047 * available to DataTables. These feature plug-ins are accessible through the sDom initialisation
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7048 * option. As such, each feature plug-in must describe a function that is used to initialise
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7049 * itself (fnInit), a character so the feature can be enabled by sDom (cFeature) and the name
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7050 * of the feature (sFeature). Thus the objects attached to this method must provide:
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7051 * <ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7052 * <li>{function} fnInit Initialisation of the plug-in
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7053 * <ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7054 * <li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7055 * Function input parameters:
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7056 * <ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7057 * <li>{object} DataTables settings object: see {@link DataTable.models.oSettings}.</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7058 * </ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7059 * </li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7060 * <li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7061 * Function return:
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7062 * <ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7063 * <li>{node|null} The element which contains your feature. Note that the return
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7064 * may also be void if your plug-in does not require to inject any DOM elements
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7065 * into DataTables control (sDom) - for example this might be useful when
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7066 * developing a plug-in which allows table control via keyboard entry.</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7067 * </ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7068 * </il>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7069 * </ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7070 * </li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7071 * <li>{character} cFeature Character that will be matched in sDom - case sensitive</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7072 * <li>{string} sFeature Feature name</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7073 * </ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7074 * @type array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7075 * @default []
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7076 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7077 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7078 * // How TableTools initialises itself.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7079 * $.fn.dataTableExt.aoFeatures.push( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7080 * "fnInit": function( oSettings ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7081 * return new TableTools( { "oDTSettings": oSettings } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7082 * },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7083 * "cFeature": "T",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7084 * "sFeature": "TableTools"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7085 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7086 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7087 "aoFeatures": [],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7088
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7089
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7090 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7091 * Type detection plug-in functions - DataTables utilises types to define how sorting and
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7092 * filtering behave, and types can be either be defined by the developer (sType for the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7093 * column) or they can be automatically detected by the methods in this array. The functions
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7094 * defined in the array are quite simple, taking a single parameter (the data to analyse)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7095 * and returning the type if it is a known type, or null otherwise.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7096 * <ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7097 * <li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7098 * Function input parameters:
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7099 * <ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7100 * <li>{*} Data from the column cell to be analysed</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7101 * </ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7102 * </li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7103 * <li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7104 * Function return:
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7105 * <ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7106 * <li>{string|null} Data type detected, or null if unknown (and thus pass it
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7107 * on to the other type detection functions.</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7108 * </ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7109 * </il>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7110 * </ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7111 * @type array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7112 * @default []
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7113 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7114 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7115 * // Currency type detection plug-in:
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7116 * jQuery.fn.dataTableExt.aTypes.push(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7117 * function ( sData ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7118 * var sValidChars = "0123456789.-";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7119 * var Char;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7120 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7121 * // Check the numeric part
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7122 * for ( i=1 ; i<sData.length ; i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7123 * Char = sData.charAt(i);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7124 * if (sValidChars.indexOf(Char) == -1) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7125 * return null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7126 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7127 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7128 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7129 * // Check prefixed by currency
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7130 * if ( sData.charAt(0) == '$' || sData.charAt(0) == '&pound;' ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7131 * return 'currency';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7132 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7133 * return null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7134 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7135 * );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7136 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7137 "aTypes": [],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7138
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7139
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7140 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7141 * Provide a common method for plug-ins to check the version of DataTables being used,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7142 * in order to ensure compatibility.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7143 * @type function
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7144 * @param {string} sVersion Version string to check for, in the format "X.Y.Z". Note
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7145 * that the formats "X" and "X.Y" are also acceptable.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7146 * @returns {boolean} true if this version of DataTables is greater or equal to the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7147 * required version, or false if this version of DataTales is not suitable
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7148 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7149 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7150 * $(document).ready(function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7151 * var oTable = $('#example').dataTable();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7152 * alert( oTable.fnVersionCheck( '1.9.0' ) );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7153 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7154 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7155 "fnVersionCheck": DataTable.fnVersionCheck,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7156
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7157
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7158 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7159 * Index for what 'this' index API functions should use
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7160 * @type int
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7161 * @default 0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7162 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7163 "iApiIndex": 0,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7164
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7165
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7166 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7167 * Pre-processing of filtering data plug-ins - When you assign the sType for a column
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7168 * (or have it automatically detected for you by DataTables or a type detection plug-in),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7169 * you will typically be using this for custom sorting, but it can also be used to provide
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7170 * custom filtering by allowing you to pre-processing the data and returning the data in
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7171 * the format that should be filtered upon. This is done by adding functions this object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7172 * with a parameter name which matches the sType for that target column. This is the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7173 * corollary of <i>afnSortData</i> for filtering data.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7174 * <ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7175 * <li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7176 * Function input parameters:
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7177 * <ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7178 * <li>{*} Data from the column cell to be prepared for filtering</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7179 * </ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7180 * </li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7181 * <li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7182 * Function return:
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7183 * <ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7184 * <li>{string|null} Formatted string that will be used for the filtering.</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7185 * </ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7186 * </il>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7187 * </ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7188 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7189 * Note that as of v1.9, it is typically preferable to use <i>mData</i> to prepare data for
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7190 * the different uses that DataTables can put the data to. Specifically <i>mData</i> when
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7191 * used as a function will give you a 'type' (sorting, filtering etc) that you can use to
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7192 * prepare the data as required for the different types. As such, this method is deprecated.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7193 * @type object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7194 * @default {}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7195 * @deprecated
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7196 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7197 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7198 * $.fn.dataTableExt.ofnSearch['title-numeric'] = function ( sData ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7199 * return sData.replace(/\n/g," ").replace( /<.*?>/g, "" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7200 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7201 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7202 "ofnSearch": {},
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7203
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7204
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7205 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7206 * Container for all private functions in DataTables so they can be exposed externally
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7207 * @type object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7208 * @default {}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7209 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7210 "oApi": {},
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7211
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7212
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7213 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7214 * Storage for the various classes that DataTables uses
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7215 * @type object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7216 * @default {}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7217 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7218 "oStdClasses": {},
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7219
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7220
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7221 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7222 * Storage for the various classes that DataTables uses - jQuery UI suitable
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7223 * @type object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7224 * @default {}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7225 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7226 "oJUIClasses": {},
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7227
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7228
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7229 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7230 * Pagination plug-in methods - The style and controls of the pagination can significantly
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7231 * impact on how the end user interacts with the data in your table, and DataTables allows
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7232 * the addition of pagination controls by extending this object, which can then be enabled
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7233 * through the <i>sPaginationType</i> initialisation parameter. Each pagination type that
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7234 * is added is an object (the property name of which is what <i>sPaginationType</i> refers
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7235 * to) that has two properties, both methods that are used by DataTables to update the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7236 * control's state.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7237 * <ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7238 * <li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7239 * fnInit - Initialisation of the paging controls. Called only during initialisation
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7240 * of the table. It is expected that this function will add the required DOM elements
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7241 * to the page for the paging controls to work. The element pointer
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7242 * 'oSettings.aanFeatures.p' array is provided by DataTables to contain the paging
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7243 * controls (note that this is a 2D array to allow for multiple instances of each
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7244 * DataTables DOM element). It is suggested that you add the controls to this element
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7245 * as children
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7246 * <ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7247 * <li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7248 * Function input parameters:
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7249 * <ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7250 * <li>{object} DataTables settings object: see {@link DataTable.models.oSettings}.</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7251 * <li>{node} Container into which the pagination controls must be inserted</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7252 * <li>{function} Draw callback function - whenever the controls cause a page
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7253 * change, this method must be called to redraw the table.</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7254 * </ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7255 * </li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7256 * <li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7257 * Function return:
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7258 * <ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7259 * <li>No return required</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7260 * </ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7261 * </il>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7262 * </ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7263 * </il>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7264 * <li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7265 * fnInit - This function is called whenever the paging status of the table changes and is
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7266 * typically used to update classes and/or text of the paging controls to reflex the new
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7267 * status.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7268 * <ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7269 * <li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7270 * Function input parameters:
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7271 * <ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7272 * <li>{object} DataTables settings object: see {@link DataTable.models.oSettings}.</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7273 * <li>{function} Draw callback function - in case you need to redraw the table again
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7274 * or attach new event listeners</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7275 * </ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7276 * </li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7277 * <li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7278 * Function return:
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7279 * <ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7280 * <li>No return required</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7281 * </ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7282 * </il>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7283 * </ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7284 * </il>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7285 * </ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7286 * @type object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7287 * @default {}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7288 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7289 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7290 * $.fn.dataTableExt.oPagination.four_button = {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7291 * "fnInit": function ( oSettings, nPaging, fnCallbackDraw ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7292 * nFirst = document.createElement( 'span' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7293 * nPrevious = document.createElement( 'span' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7294 * nNext = document.createElement( 'span' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7295 * nLast = document.createElement( 'span' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7296 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7297 * nFirst.appendChild( document.createTextNode( oSettings.oLanguage.oPaginate.sFirst ) );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7298 * nPrevious.appendChild( document.createTextNode( oSettings.oLanguage.oPaginate.sPrevious ) );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7299 * nNext.appendChild( document.createTextNode( oSettings.oLanguage.oPaginate.sNext ) );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7300 * nLast.appendChild( document.createTextNode( oSettings.oLanguage.oPaginate.sLast ) );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7301 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7302 * nFirst.className = "paginate_button first";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7303 * nPrevious.className = "paginate_button previous";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7304 * nNext.className="paginate_button next";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7305 * nLast.className = "paginate_button last";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7306 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7307 * nPaging.appendChild( nFirst );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7308 * nPaging.appendChild( nPrevious );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7309 * nPaging.appendChild( nNext );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7310 * nPaging.appendChild( nLast );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7311 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7312 * $(nFirst).click( function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7313 * oSettings.oApi._fnPageChange( oSettings, "first" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7314 * fnCallbackDraw( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7315 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7316 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7317 * $(nPrevious).click( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7318 * oSettings.oApi._fnPageChange( oSettings, "previous" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7319 * fnCallbackDraw( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7320 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7321 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7322 * $(nNext).click( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7323 * oSettings.oApi._fnPageChange( oSettings, "next" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7324 * fnCallbackDraw( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7325 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7326 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7327 * $(nLast).click( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7328 * oSettings.oApi._fnPageChange( oSettings, "last" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7329 * fnCallbackDraw( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7330 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7331 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7332 * $(nFirst).bind( 'selectstart', function () { return false; } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7333 * $(nPrevious).bind( 'selectstart', function () { return false; } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7334 * $(nNext).bind( 'selectstart', function () { return false; } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7335 * $(nLast).bind( 'selectstart', function () { return false; } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7336 * },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7337 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7338 * "fnUpdate": function ( oSettings, fnCallbackDraw ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7339 * if ( !oSettings.aanFeatures.p ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7340 * return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7341 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7342 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7343 * // Loop over each instance of the pager
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7344 * var an = oSettings.aanFeatures.p;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7345 * for ( var i=0, iLen=an.length ; i<iLen ; i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7346 * var buttons = an[i].getElementsByTagName('span');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7347 * if ( oSettings._iDisplayStart === 0 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7348 * buttons[0].className = "paginate_disabled_previous";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7349 * buttons[1].className = "paginate_disabled_previous";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7350 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7351 * else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7352 * buttons[0].className = "paginate_enabled_previous";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7353 * buttons[1].className = "paginate_enabled_previous";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7354 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7355 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7356 * if ( oSettings.fnDisplayEnd() == oSettings.fnRecordsDisplay() ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7357 * buttons[2].className = "paginate_disabled_next";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7358 * buttons[3].className = "paginate_disabled_next";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7359 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7360 * else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7361 * buttons[2].className = "paginate_enabled_next";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7362 * buttons[3].className = "paginate_enabled_next";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7363 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7364 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7365 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7366 * };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7367 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7368 "oPagination": {},
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7369
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7370
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7371 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7372 * Sorting plug-in methods - Sorting in DataTables is based on the detected type of the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7373 * data column (you can add your own type detection functions, or override automatic
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7374 * detection using sType). With this specific type given to the column, DataTables will
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7375 * apply the required sort from the functions in the object. Each sort type must provide
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7376 * two mandatory methods, one each for ascending and descending sorting, and can optionally
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7377 * provide a pre-formatting method that will help speed up sorting by allowing DataTables
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7378 * to pre-format the sort data only once (rather than every time the actual sort functions
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7379 * are run). The two sorting functions are typical Javascript sort methods:
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7380 * <ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7381 * <li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7382 * Function input parameters:
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7383 * <ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7384 * <li>{*} Data to compare to the second parameter</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7385 * <li>{*} Data to compare to the first parameter</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7386 * </ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7387 * </li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7388 * <li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7389 * Function return:
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7390 * <ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7391 * <li>{int} Sorting match: <0 if first parameter should be sorted lower than
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7392 * the second parameter, ===0 if the two parameters are equal and >0 if
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7393 * the first parameter should be sorted height than the second parameter.</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7394 * </ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7395 * </il>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7396 * </ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7397 * @type object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7398 * @default {}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7399 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7400 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7401 * // Case-sensitive string sorting, with no pre-formatting method
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7402 * $.extend( $.fn.dataTableExt.oSort, {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7403 * "string-case-asc": function(x,y) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7404 * return ((x < y) ? -1 : ((x > y) ? 1 : 0));
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7405 * },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7406 * "string-case-desc": function(x,y) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7407 * return ((x < y) ? 1 : ((x > y) ? -1 : 0));
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7408 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7409 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7410 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7411 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7412 * // Case-insensitive string sorting, with pre-formatting
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7413 * $.extend( $.fn.dataTableExt.oSort, {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7414 * "string-pre": function(x) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7415 * return x.toLowerCase();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7416 * },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7417 * "string-asc": function(x,y) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7418 * return ((x < y) ? -1 : ((x > y) ? 1 : 0));
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7419 * },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7420 * "string-desc": function(x,y) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7421 * return ((x < y) ? 1 : ((x > y) ? -1 : 0));
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7422 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7423 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7424 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7425 "oSort": {},
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7426
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7427
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7428 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7429 * Version string for plug-ins to check compatibility. Allowed format is
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7430 * a.b.c.d.e where: a:int, b:int, c:int, d:string(dev|beta), e:int. d and
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7431 * e are optional
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7432 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7433 * @default Version number
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7434 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7435 "sVersion": DataTable.version,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7436
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7437
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7438 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7439 * How should DataTables report an error. Can take the value 'alert' or 'throw'
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7440 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7441 * @default alert
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7442 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7443 "sErrMode": "alert",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7444
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7445
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7446 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7447 * Store information for DataTables to access globally about other instances
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7448 * @namespace
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7449 * @private
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7450 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7451 "_oExternConfig": {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7452 /* int:iNextUnique - next unique number for an instance */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7453 "iNextUnique": 0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7454 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7455 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7456
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7457
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7458
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7459
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7460 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7461 * Template object for the way in which DataTables holds information about
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7462 * search information for the global filter and individual column filters.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7463 * @namespace
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7464 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7465 DataTable.models.oSearch = {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7466 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7467 * Flag to indicate if the filtering should be case insensitive or not
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7468 * @type boolean
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7469 * @default true
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7470 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7471 "bCaseInsensitive": true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7472
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7473 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7474 * Applied search term
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7475 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7476 * @default <i>Empty string</i>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7477 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7478 "sSearch": "",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7479
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7480 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7481 * Flag to indicate if the search term should be interpreted as a
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7482 * regular expression (true) or not (false) and therefore and special
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7483 * regex characters escaped.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7484 * @type boolean
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7485 * @default false
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7486 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7487 "bRegex": false,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7488
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7489 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7490 * Flag to indicate if DataTables is to use its smart filtering or not.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7491 * @type boolean
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7492 * @default true
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7493 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7494 "bSmart": true
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7495 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7496
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7497
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7498
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7499
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7500 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7501 * Template object for the way in which DataTables holds information about
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7502 * each individual row. This is the object format used for the settings
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7503 * aoData array.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7504 * @namespace
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7505 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7506 DataTable.models.oRow = {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7507 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7508 * TR element for the row
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7509 * @type node
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7510 * @default null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7511 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7512 "nTr": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7513
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7514 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7515 * Data object from the original data source for the row. This is either
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7516 * an array if using the traditional form of DataTables, or an object if
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7517 * using mData options. The exact type will depend on the passed in
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7518 * data from the data source, or will be an array if using DOM a data
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7519 * source.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7520 * @type array|object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7521 * @default []
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7522 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7523 "_aData": [],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7524
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7525 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7526 * Sorting data cache - this array is ostensibly the same length as the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7527 * number of columns (although each index is generated only as it is
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7528 * needed), and holds the data that is used for sorting each column in the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7529 * row. We do this cache generation at the start of the sort in order that
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7530 * the formatting of the sort data need be done only once for each cell
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7531 * per sort. This array should not be read from or written to by anything
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7532 * other than the master sorting methods.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7533 * @type array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7534 * @default []
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7535 * @private
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7536 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7537 "_aSortData": [],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7538
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7539 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7540 * Array of TD elements that are cached for hidden rows, so they can be
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7541 * reinserted into the table if a column is made visible again (or to act
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7542 * as a store if a column is made hidden). Only hidden columns have a
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7543 * reference in the array. For non-hidden columns the value is either
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7544 * undefined or null.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7545 * @type array nodes
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7546 * @default []
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7547 * @private
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7548 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7549 "_anHidden": [],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7550
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7551 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7552 * Cache of the class name that DataTables has applied to the row, so we
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7553 * can quickly look at this variable rather than needing to do a DOM check
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7554 * on className for the nTr property.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7555 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7556 * @default <i>Empty string</i>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7557 * @private
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7558 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7559 "_sRowStripe": ""
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7560 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7561
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7562
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7563
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7564 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7565 * Template object for the column information object in DataTables. This object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7566 * is held in the settings aoColumns array and contains all the information that
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7567 * DataTables needs about each individual column.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7568 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7569 * Note that this object is related to {@link DataTable.defaults.columns}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7570 * but this one is the internal data store for DataTables's cache of columns.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7571 * It should NOT be manipulated outside of DataTables. Any configuration should
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7572 * be done through the initialisation options.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7573 * @namespace
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7574 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7575 DataTable.models.oColumn = {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7576 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7577 * A list of the columns that sorting should occur on when this column
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7578 * is sorted. That this property is an array allows multi-column sorting
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7579 * to be defined for a column (for example first name / last name columns
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7580 * would benefit from this). The values are integers pointing to the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7581 * columns to be sorted on (typically it will be a single integer pointing
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7582 * at itself, but that doesn't need to be the case).
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7583 * @type array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7584 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7585 "aDataSort": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7586
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7587 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7588 * Define the sorting directions that are applied to the column, in sequence
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7589 * as the column is repeatedly sorted upon - i.e. the first value is used
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7590 * as the sorting direction when the column if first sorted (clicked on).
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7591 * Sort it again (click again) and it will move on to the next index.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7592 * Repeat until loop.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7593 * @type array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7594 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7595 "asSorting": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7596
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7597 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7598 * Flag to indicate if the column is searchable, and thus should be included
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7599 * in the filtering or not.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7600 * @type boolean
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7601 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7602 "bSearchable": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7603
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7604 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7605 * Flag to indicate if the column is sortable or not.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7606 * @type boolean
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7607 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7608 "bSortable": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7609
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7610 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7611 * <code>Deprecated</code> When using fnRender, you have two options for what
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7612 * to do with the data, and this property serves as the switch. Firstly, you
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7613 * can have the sorting and filtering use the rendered value (true - default),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7614 * or you can have the sorting and filtering us the original value (false).
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7615 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7616 * Please note that this option has now been deprecated and will be removed
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7617 * in the next version of DataTables. Please use mRender / mData rather than
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7618 * fnRender.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7619 * @type boolean
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7620 * @deprecated
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7621 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7622 "bUseRendered": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7623
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7624 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7625 * Flag to indicate if the column is currently visible in the table or not
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7626 * @type boolean
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7627 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7628 "bVisible": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7629
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7630 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7631 * Flag to indicate to the type detection method if the automatic type
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7632 * detection should be used, or if a column type (sType) has been specified
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7633 * @type boolean
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7634 * @default true
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7635 * @private
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7636 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7637 "_bAutoType": true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7638
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7639 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7640 * Developer definable function that is called whenever a cell is created (Ajax source,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7641 * etc) or processed for input (DOM source). This can be used as a compliment to mRender
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7642 * allowing you to modify the DOM element (add background colour for example) when the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7643 * element is available.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7644 * @type function
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7645 * @param {element} nTd The TD node that has been created
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7646 * @param {*} sData The Data for the cell
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7647 * @param {array|object} oData The data for the whole row
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7648 * @param {int} iRow The row index for the aoData data store
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7649 * @default null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7650 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7651 "fnCreatedCell": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7652
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7653 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7654 * Function to get data from a cell in a column. You should <b>never</b>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7655 * access data directly through _aData internally in DataTables - always use
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7656 * the method attached to this property. It allows mData to function as
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7657 * required. This function is automatically assigned by the column
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7658 * initialisation method
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7659 * @type function
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7660 * @param {array|object} oData The data array/object for the array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7661 * (i.e. aoData[]._aData)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7662 * @param {string} sSpecific The specific data type you want to get -
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7663 * 'display', 'type' 'filter' 'sort'
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7664 * @returns {*} The data for the cell from the given row's data
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7665 * @default null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7666 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7667 "fnGetData": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7668
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7669 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7670 * <code>Deprecated</code> Custom display function that will be called for the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7671 * display of each cell in this column.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7672 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7673 * Please note that this option has now been deprecated and will be removed
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7674 * in the next version of DataTables. Please use mRender / mData rather than
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7675 * fnRender.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7676 * @type function
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7677 * @param {object} o Object with the following parameters:
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7678 * @param {int} o.iDataRow The row in aoData
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7679 * @param {int} o.iDataColumn The column in question
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7680 * @param {array} o.aData The data for the row in question
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7681 * @param {object} o.oSettings The settings object for this DataTables instance
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7682 * @returns {string} The string you which to use in the display
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7683 * @default null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7684 * @deprecated
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7685 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7686 "fnRender": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7687
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7688 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7689 * Function to set data for a cell in the column. You should <b>never</b>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7690 * set the data directly to _aData internally in DataTables - always use
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7691 * this method. It allows mData to function as required. This function
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7692 * is automatically assigned by the column initialisation method
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7693 * @type function
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7694 * @param {array|object} oData The data array/object for the array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7695 * (i.e. aoData[]._aData)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7696 * @param {*} sValue Value to set
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7697 * @default null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7698 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7699 "fnSetData": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7700
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7701 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7702 * Property to read the value for the cells in the column from the data
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7703 * source array / object. If null, then the default content is used, if a
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7704 * function is given then the return from the function is used.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7705 * @type function|int|string|null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7706 * @default null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7707 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7708 "mData": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7709
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7710 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7711 * Partner property to mData which is used (only when defined) to get
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7712 * the data - i.e. it is basically the same as mData, but without the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7713 * 'set' option, and also the data fed to it is the result from mData.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7714 * This is the rendering method to match the data method of mData.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7715 * @type function|int|string|null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7716 * @default null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7717 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7718 "mRender": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7719
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7720 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7721 * Unique header TH/TD element for this column - this is what the sorting
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7722 * listener is attached to (if sorting is enabled.)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7723 * @type node
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7724 * @default null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7725 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7726 "nTh": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7727
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7728 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7729 * Unique footer TH/TD element for this column (if there is one). Not used
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7730 * in DataTables as such, but can be used for plug-ins to reference the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7731 * footer for each column.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7732 * @type node
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7733 * @default null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7734 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7735 "nTf": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7736
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7737 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7738 * The class to apply to all TD elements in the table's TBODY for the column
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7739 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7740 * @default null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7741 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7742 "sClass": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7743
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7744 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7745 * When DataTables calculates the column widths to assign to each column,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7746 * it finds the longest string in each column and then constructs a
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7747 * temporary table and reads the widths from that. The problem with this
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7748 * is that "mmm" is much wider then "iiii", but the latter is a longer
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7749 * string - thus the calculation can go wrong (doing it properly and putting
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7750 * it into an DOM object and measuring that is horribly(!) slow). Thus as
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7751 * a "work around" we provide this option. It will append its value to the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7752 * text that is found to be the longest string for the column - i.e. padding.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7753 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7754 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7755 "sContentPadding": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7756
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7757 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7758 * Allows a default value to be given for a column's data, and will be used
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7759 * whenever a null data source is encountered (this can be because mData
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7760 * is set to null, or because the data source itself is null).
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7761 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7762 * @default null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7763 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7764 "sDefaultContent": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7765
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7766 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7767 * Name for the column, allowing reference to the column by name as well as
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7768 * by index (needs a lookup to work by name).
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7769 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7770 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7771 "sName": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7772
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7773 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7774 * Custom sorting data type - defines which of the available plug-ins in
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7775 * afnSortData the custom sorting will use - if any is defined.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7776 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7777 * @default std
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7778 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7779 "sSortDataType": 'std',
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7780
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7781 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7782 * Class to be applied to the header element when sorting on this column
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7783 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7784 * @default null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7785 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7786 "sSortingClass": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7787
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7788 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7789 * Class to be applied to the header element when sorting on this column -
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7790 * when jQuery UI theming is used.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7791 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7792 * @default null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7793 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7794 "sSortingClassJUI": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7795
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7796 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7797 * Title of the column - what is seen in the TH element (nTh).
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7798 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7799 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7800 "sTitle": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7801
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7802 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7803 * Column sorting and filtering type
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7804 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7805 * @default null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7806 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7807 "sType": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7808
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7809 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7810 * Width of the column
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7811 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7812 * @default null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7813 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7814 "sWidth": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7815
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7816 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7817 * Width of the column when it was first "encountered"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7818 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7819 * @default null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7820 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7821 "sWidthOrig": null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7822 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7823
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7824
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7825
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7826 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7827 * Initialisation options that can be given to DataTables at initialisation
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7828 * time.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7829 * @namespace
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7830 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7831 DataTable.defaults = {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7832 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7833 * An array of data to use for the table, passed in at initialisation which
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7834 * will be used in preference to any data which is already in the DOM. This is
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7835 * particularly useful for constructing tables purely in Javascript, for
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7836 * example with a custom Ajax call.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7837 * @type array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7838 * @default null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7839 * @dtopt Option
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7840 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7841 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7842 * // Using a 2D array data source
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7843 * $(document).ready( function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7844 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7845 * "aaData": [
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7846 * ['Trident', 'Internet Explorer 4.0', 'Win 95+', 4, 'X'],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7847 * ['Trident', 'Internet Explorer 5.0', 'Win 95+', 5, 'C'],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7848 * ],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7849 * "aoColumns": [
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7850 * { "sTitle": "Engine" },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7851 * { "sTitle": "Browser" },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7852 * { "sTitle": "Platform" },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7853 * { "sTitle": "Version" },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7854 * { "sTitle": "Grade" }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7855 * ]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7856 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7857 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7858 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7859 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7860 * // Using an array of objects as a data source (mData)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7861 * $(document).ready( function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7862 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7863 * "aaData": [
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7864 * {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7865 * "engine": "Trident",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7866 * "browser": "Internet Explorer 4.0",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7867 * "platform": "Win 95+",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7868 * "version": 4,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7869 * "grade": "X"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7870 * },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7871 * {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7872 * "engine": "Trident",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7873 * "browser": "Internet Explorer 5.0",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7874 * "platform": "Win 95+",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7875 * "version": 5,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7876 * "grade": "C"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7877 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7878 * ],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7879 * "aoColumns": [
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7880 * { "sTitle": "Engine", "mData": "engine" },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7881 * { "sTitle": "Browser", "mData": "browser" },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7882 * { "sTitle": "Platform", "mData": "platform" },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7883 * { "sTitle": "Version", "mData": "version" },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7884 * { "sTitle": "Grade", "mData": "grade" }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7885 * ]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7886 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7887 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7888 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7889 "aaData": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7890
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7891
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7892 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7893 * If sorting is enabled, then DataTables will perform a first pass sort on
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7894 * initialisation. You can define which column(s) the sort is performed upon,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7895 * and the sorting direction, with this variable. The aaSorting array should
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7896 * contain an array for each column to be sorted initially containing the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7897 * column's index and a direction string ('asc' or 'desc').
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7898 * @type array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7899 * @default [[0,'asc']]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7900 * @dtopt Option
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7901 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7902 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7903 * // Sort by 3rd column first, and then 4th column
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7904 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7905 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7906 * "aaSorting": [[2,'asc'], [3,'desc']]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7907 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7908 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7909 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7910 * // No initial sorting
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7911 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7912 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7913 * "aaSorting": []
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7914 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7915 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7916 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7917 "aaSorting": [[0,'asc']],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7918
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7919
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7920 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7921 * This parameter is basically identical to the aaSorting parameter, but
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7922 * cannot be overridden by user interaction with the table. What this means
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7923 * is that you could have a column (visible or hidden) which the sorting will
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7924 * always be forced on first - any sorting after that (from the user) will
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7925 * then be performed as required. This can be useful for grouping rows
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7926 * together.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7927 * @type array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7928 * @default null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7929 * @dtopt Option
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7930 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7931 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7932 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7933 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7934 * "aaSortingFixed": [[0,'asc']]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7935 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7936 * } )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7937 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7938 "aaSortingFixed": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7939
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7940
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7941 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7942 * This parameter allows you to readily specify the entries in the length drop
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7943 * down menu that DataTables shows when pagination is enabled. It can be
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7944 * either a 1D array of options which will be used for both the displayed
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7945 * option and the value, or a 2D array which will use the array in the first
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7946 * position as the value, and the array in the second position as the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7947 * displayed options (useful for language strings such as 'All').
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7948 * @type array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7949 * @default [ 10, 25, 50, 100 ]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7950 * @dtopt Option
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7951 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7952 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7953 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7954 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7955 * "aLengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7956 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7957 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7958 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7959 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7960 * // Setting the default display length as well as length menu
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7961 * // This is likely to be wanted if you remove the '10' option which
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7962 * // is the iDisplayLength default.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7963 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7964 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7965 * "iDisplayLength": 25,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7966 * "aLengthMenu": [[25, 50, 100, -1], [25, 50, 100, "All"]]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7967 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7968 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7969 */
6
42076db43d42 Fixed auto resizing plus various other minor bugs
saskia-hiltemann
parents: 0
diff changeset
7970 "aLengthMenu": [[10, 25, 50, 100, 250, 500, 1000, -1], [10, 25, 50, 100, 250, 500, 1000, "All"]],
0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7971
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7972
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7973 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7974 * The aoColumns option in the initialisation parameter allows you to define
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7975 * details about the way individual columns behave. For a full list of
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7976 * column options that can be set, please see
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7977 * {@link DataTable.defaults.columns}. Note that if you use aoColumns to
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7978 * define your columns, you must have an entry in the array for every single
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7979 * column that you have in your table (these can be null if you don't which
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7980 * to specify any options).
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7981 * @member
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7982 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7983 "aoColumns": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7984
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7985 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7986 * Very similar to aoColumns, aoColumnDefs allows you to target a specific
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7987 * column, multiple columns, or all columns, using the aTargets property of
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7988 * each object in the array. This allows great flexibility when creating
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7989 * tables, as the aoColumnDefs arrays can be of any length, targeting the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7990 * columns you specifically want. aoColumnDefs may use any of the column
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7991 * options available: {@link DataTable.defaults.columns}, but it _must_
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7992 * have aTargets defined in each object in the array. Values in the aTargets
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7993 * array may be:
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7994 * <ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7995 * <li>a string - class name will be matched on the TH for the column</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7996 * <li>0 or a positive integer - column index counting from the left</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7997 * <li>a negative integer - column index counting from the right</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7998 * <li>the string "_all" - all columns (i.e. assign a default)</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7999 * </ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8000 * @member
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8001 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8002 "aoColumnDefs": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8003
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8004
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8005 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8006 * Basically the same as oSearch, this parameter defines the individual column
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8007 * filtering state at initialisation time. The array must be of the same size
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8008 * as the number of columns, and each element be an object with the parameters
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8009 * "sSearch" and "bEscapeRegex" (the latter is optional). 'null' is also
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8010 * accepted and the default will be used.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8011 * @type array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8012 * @default []
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8013 * @dtopt Option
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8014 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8015 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8016 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8017 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8018 * "aoSearchCols": [
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8019 * null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8020 * { "sSearch": "My filter" },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8021 * null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8022 * { "sSearch": "^[0-9]", "bEscapeRegex": false }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8023 * ]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8024 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8025 * } )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8026 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8027 "aoSearchCols": [],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8028
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8029
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8030 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8031 * An array of CSS classes that should be applied to displayed rows. This
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8032 * array may be of any length, and DataTables will apply each class
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8033 * sequentially, looping when required.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8034 * @type array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8035 * @default null <i>Will take the values determined by the oClasses.sStripe*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8036 * options</i>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8037 * @dtopt Option
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8038 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8039 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8040 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8041 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8042 * "asStripeClasses": [ 'strip1', 'strip2', 'strip3' ]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8043 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8044 * } )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8045 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8046 "asStripeClasses": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8047
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8048
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8049 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8050 * Enable or disable automatic column width calculation. This can be disabled
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8051 * as an optimisation (it takes some time to calculate the widths) if the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8052 * tables widths are passed in using aoColumns.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8053 * @type boolean
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8054 * @default true
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8055 * @dtopt Features
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8056 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8057 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8058 * $(document).ready( function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8059 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8060 * "bAutoWidth": false
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8061 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8062 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8063 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8064 "bAutoWidth": true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8065
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8066
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8067 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8068 * Deferred rendering can provide DataTables with a huge speed boost when you
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8069 * are using an Ajax or JS data source for the table. This option, when set to
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8070 * true, will cause DataTables to defer the creation of the table elements for
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8071 * each row until they are needed for a draw - saving a significant amount of
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8072 * time.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8073 * @type boolean
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8074 * @default false
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8075 * @dtopt Features
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8076 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8077 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8078 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8079 * var oTable = $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8080 * "sAjaxSource": "sources/arrays.txt",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8081 * "bDeferRender": true
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8082 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8083 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8084 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8085 "bDeferRender": false,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8086
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8087
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8088 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8089 * Replace a DataTable which matches the given selector and replace it with
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8090 * one which has the properties of the new initialisation object passed. If no
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8091 * table matches the selector, then the new DataTable will be constructed as
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8092 * per normal.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8093 * @type boolean
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8094 * @default false
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8095 * @dtopt Options
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8096 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8097 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8098 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8099 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8100 * "sScrollY": "200px",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8101 * "bPaginate": false
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8102 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8103 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8104 * // Some time later....
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8105 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8106 * "bFilter": false,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8107 * "bDestroy": true
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8108 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8109 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8110 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8111 "bDestroy": false,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8112
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8113
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8114 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8115 * Enable or disable filtering of data. Filtering in DataTables is "smart" in
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8116 * that it allows the end user to input multiple words (space separated) and
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8117 * will match a row containing those words, even if not in the order that was
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8118 * specified (this allow matching across multiple columns). Note that if you
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8119 * wish to use filtering in DataTables this must remain 'true' - to remove the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8120 * default filtering input box and retain filtering abilities, please use
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8121 * {@link DataTable.defaults.sDom}.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8122 * @type boolean
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8123 * @default true
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8124 * @dtopt Features
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8125 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8126 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8127 * $(document).ready( function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8128 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8129 * "bFilter": false
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8130 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8131 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8132 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8133 "bFilter": true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8134
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8135
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8136 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8137 * Enable or disable the table information display. This shows information
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8138 * about the data that is currently visible on the page, including information
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8139 * about filtered data if that action is being performed.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8140 * @type boolean
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8141 * @default true
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8142 * @dtopt Features
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8143 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8144 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8145 * $(document).ready( function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8146 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8147 * "bInfo": false
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8148 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8149 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8150 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8151 "bInfo": true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8152
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8153
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8154 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8155 * Enable jQuery UI ThemeRoller support (required as ThemeRoller requires some
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8156 * slightly different and additional mark-up from what DataTables has
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8157 * traditionally used).
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8158 * @type boolean
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8159 * @default false
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8160 * @dtopt Features
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8161 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8162 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8163 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8164 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8165 * "bJQueryUI": true
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8166 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8167 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8168 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8169 "bJQueryUI": false,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8170
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8171
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8172 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8173 * Allows the end user to select the size of a formatted page from a select
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8174 * menu (sizes are 10, 25, 50 and 100). Requires pagination (bPaginate).
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8175 * @type boolean
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8176 * @default true
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8177 * @dtopt Features
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8178 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8179 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8180 * $(document).ready( function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8181 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8182 * "bLengthChange": false
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8183 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8184 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8185 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8186 "bLengthChange": true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8187
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8188
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8189 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8190 * Enable or disable pagination.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8191 * @type boolean
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8192 * @default true
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8193 * @dtopt Features
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8194 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8195 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8196 * $(document).ready( function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8197 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8198 * "bPaginate": false
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8199 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8200 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8201 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8202 "bPaginate": true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8203
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8204
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8205 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8206 * Enable or disable the display of a 'processing' indicator when the table is
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8207 * being processed (e.g. a sort). This is particularly useful for tables with
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8208 * large amounts of data where it can take a noticeable amount of time to sort
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8209 * the entries.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8210 * @type boolean
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8211 * @default false
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8212 * @dtopt Features
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8213 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8214 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8215 * $(document).ready( function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8216 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8217 * "bProcessing": true
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8218 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8219 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8220 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8221 "bProcessing": false,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8222
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8223
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8224 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8225 * Retrieve the DataTables object for the given selector. Note that if the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8226 * table has already been initialised, this parameter will cause DataTables
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8227 * to simply return the object that has already been set up - it will not take
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8228 * account of any changes you might have made to the initialisation object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8229 * passed to DataTables (setting this parameter to true is an acknowledgement
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8230 * that you understand this). bDestroy can be used to reinitialise a table if
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8231 * you need.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8232 * @type boolean
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8233 * @default false
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8234 * @dtopt Options
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8235 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8236 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8237 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8238 * initTable();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8239 * tableActions();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8240 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8241 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8242 * function initTable ()
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8243 * {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8244 * return $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8245 * "sScrollY": "200px",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8246 * "bPaginate": false,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8247 * "bRetrieve": true
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8248 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8249 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8250 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8251 * function tableActions ()
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8252 * {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8253 * var oTable = initTable();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8254 * // perform API operations with oTable
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8255 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8256 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8257 "bRetrieve": false,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8258
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8259
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8260 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8261 * Indicate if DataTables should be allowed to set the padding / margin
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8262 * etc for the scrolling header elements or not. Typically you will want
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8263 * this.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8264 * @type boolean
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8265 * @default true
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8266 * @dtopt Options
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8267 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8268 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8269 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8270 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8271 * "bScrollAutoCss": false,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8272 * "sScrollY": "200px"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8273 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8274 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8275 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8276 "bScrollAutoCss": true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8277
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8278
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8279 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8280 * When vertical (y) scrolling is enabled, DataTables will force the height of
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8281 * the table's viewport to the given height at all times (useful for layout).
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8282 * However, this can look odd when filtering data down to a small data set,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8283 * and the footer is left "floating" further down. This parameter (when
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8284 * enabled) will cause DataTables to collapse the table's viewport down when
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8285 * the result set will fit within the given Y height.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8286 * @type boolean
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8287 * @default false
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8288 * @dtopt Options
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8289 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8290 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8291 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8292 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8293 * "sScrollY": "200",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8294 * "bScrollCollapse": true
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8295 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8296 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8297 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8298 "bScrollCollapse": false,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8299
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8300
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8301 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8302 * Enable infinite scrolling for DataTables (to be used in combination with
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8303 * sScrollY). Infinite scrolling means that DataTables will continually load
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8304 * data as a user scrolls through a table, which is very useful for large
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8305 * dataset. This cannot be used with pagination, which is automatically
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8306 * disabled. Note - the Scroller extra for DataTables is recommended in
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8307 * in preference to this option.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8308 * @type boolean
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8309 * @default false
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8310 * @dtopt Features
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8311 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8312 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8313 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8314 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8315 * "bScrollInfinite": true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8316 * "bScrollCollapse": true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8317 * "sScrollY": "200px"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8318 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8319 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8320 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8321 "bScrollInfinite": false,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8322
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8323
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8324 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8325 * Configure DataTables to use server-side processing. Note that the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8326 * sAjaxSource parameter must also be given in order to give DataTables a
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8327 * source to obtain the required data for each draw.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8328 * @type boolean
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8329 * @default false
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8330 * @dtopt Features
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8331 * @dtopt Server-side
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8332 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8333 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8334 * $(document).ready( function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8335 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8336 * "bServerSide": true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8337 * "sAjaxSource": "xhr.php"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8338 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8339 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8340 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8341 "bServerSide": false,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8342
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8343
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8344 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8345 * Enable or disable sorting of columns. Sorting of individual columns can be
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8346 * disabled by the "bSortable" option for each column.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8347 * @type boolean
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8348 * @default true
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8349 * @dtopt Features
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8350 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8351 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8352 * $(document).ready( function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8353 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8354 * "bSort": false
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8355 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8356 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8357 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8358 "bSort": true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8359
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8360
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8361 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8362 * Allows control over whether DataTables should use the top (true) unique
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8363 * cell that is found for a single column, or the bottom (false - default).
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8364 * This is useful when using complex headers.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8365 * @type boolean
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8366 * @default false
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8367 * @dtopt Options
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8368 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8369 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8370 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8371 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8372 * "bSortCellsTop": true
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8373 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8374 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8375 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8376 "bSortCellsTop": false,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8377
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8378
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8379 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8380 * Enable or disable the addition of the classes 'sorting_1', 'sorting_2' and
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8381 * 'sorting_3' to the columns which are currently being sorted on. This is
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8382 * presented as a feature switch as it can increase processing time (while
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8383 * classes are removed and added) so for large data sets you might want to
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8384 * turn this off.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8385 * @type boolean
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8386 * @default true
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8387 * @dtopt Features
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8388 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8389 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8390 * $(document).ready( function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8391 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8392 * "bSortClasses": false
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8393 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8394 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8395 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8396 "bSortClasses": true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8397
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8398
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8399 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8400 * Enable or disable state saving. When enabled a cookie will be used to save
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8401 * table display information such as pagination information, display length,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8402 * filtering and sorting. As such when the end user reloads the page the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8403 * display display will match what thy had previously set up.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8404 * @type boolean
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8405 * @default false
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8406 * @dtopt Features
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8407 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8408 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8409 * $(document).ready( function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8410 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8411 * "bStateSave": true
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8412 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8413 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8414 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8415 "bStateSave": false,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8416
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8417
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8418 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8419 * Customise the cookie and / or the parameters being stored when using
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8420 * DataTables with state saving enabled. This function is called whenever
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8421 * the cookie is modified, and it expects a fully formed cookie string to be
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8422 * returned. Note that the data object passed in is a Javascript object which
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8423 * must be converted to a string (JSON.stringify for example).
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8424 * @type function
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8425 * @param {string} sName Name of the cookie defined by DataTables
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8426 * @param {object} oData Data to be stored in the cookie
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8427 * @param {string} sExpires Cookie expires string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8428 * @param {string} sPath Path of the cookie to set
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8429 * @returns {string} Cookie formatted string (which should be encoded by
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8430 * using encodeURIComponent())
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8431 * @dtopt Callbacks
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8432 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8433 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8434 * $(document).ready( function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8435 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8436 * "fnCookieCallback": function (sName, oData, sExpires, sPath) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8437 * // Customise oData or sName or whatever else here
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8438 * return sName + "="+JSON.stringify(oData)+"; expires=" + sExpires +"; path=" + sPath;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8439 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8440 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8441 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8442 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8443 "fnCookieCallback": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8444
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8445
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8446 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8447 * This function is called when a TR element is created (and all TD child
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8448 * elements have been inserted), or registered if using a DOM source, allowing
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8449 * manipulation of the TR element (adding classes etc).
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8450 * @type function
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8451 * @param {node} nRow "TR" element for the current row
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8452 * @param {array} aData Raw data array for this row
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8453 * @param {int} iDataIndex The index of this row in aoData
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8454 * @dtopt Callbacks
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8455 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8456 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8457 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8458 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8459 * "fnCreatedRow": function( nRow, aData, iDataIndex ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8460 * // Bold the grade for all 'A' grade browsers
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8461 * if ( aData[4] == "A" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8462 * {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8463 * $('td:eq(4)', nRow).html( '<b>A</b>' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8464 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8465 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8466 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8467 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8468 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8469 "fnCreatedRow": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8470
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8471
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8472 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8473 * This function is called on every 'draw' event, and allows you to
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8474 * dynamically modify any aspect you want about the created DOM.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8475 * @type function
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8476 * @param {object} oSettings DataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8477 * @dtopt Callbacks
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8478 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8479 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8480 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8481 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8482 * "fnDrawCallback": function( oSettings ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8483 * alert( 'DataTables has redrawn the table' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8484 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8485 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8486 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8487 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8488 "fnDrawCallback": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8489
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8490
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8491 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8492 * Identical to fnHeaderCallback() but for the table footer this function
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8493 * allows you to modify the table footer on every 'draw' even.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8494 * @type function
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8495 * @param {node} nFoot "TR" element for the footer
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8496 * @param {array} aData Full table data (as derived from the original HTML)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8497 * @param {int} iStart Index for the current display starting point in the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8498 * display array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8499 * @param {int} iEnd Index for the current display ending point in the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8500 * display array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8501 * @param {array int} aiDisplay Index array to translate the visual position
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8502 * to the full data array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8503 * @dtopt Callbacks
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8504 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8505 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8506 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8507 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8508 * "fnFooterCallback": function( nFoot, aData, iStart, iEnd, aiDisplay ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8509 * nFoot.getElementsByTagName('th')[0].innerHTML = "Starting index is "+iStart;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8510 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8511 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8512 * } )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8513 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8514 "fnFooterCallback": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8515
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8516
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8517 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8518 * When rendering large numbers in the information element for the table
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8519 * (i.e. "Showing 1 to 10 of 57 entries") DataTables will render large numbers
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8520 * to have a comma separator for the 'thousands' units (e.g. 1 million is
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8521 * rendered as "1,000,000") to help readability for the end user. This
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8522 * function will override the default method DataTables uses.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8523 * @type function
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8524 * @member
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8525 * @param {int} iIn number to be formatted
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8526 * @returns {string} formatted string for DataTables to show the number
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8527 * @dtopt Callbacks
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8528 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8529 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8530 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8531 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8532 * "fnFormatNumber": function ( iIn ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8533 * if ( iIn &lt; 1000 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8534 * return iIn;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8535 * } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8536 * var
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8537 * s=(iIn+""),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8538 * a=s.split(""), out="",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8539 * iLen=s.length;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8540 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8541 * for ( var i=0 ; i&lt;iLen ; i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8542 * if ( i%3 === 0 &amp;&amp; i !== 0 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8543 * out = "'"+out;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8544 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8545 * out = a[iLen-i-1]+out;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8546 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8547 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8548 * return out;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8549 * };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8550 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8551 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8552 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8553 "fnFormatNumber": function ( iIn ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8554 if ( iIn < 1000 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8555 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8556 // A small optimisation for what is likely to be the majority of use cases
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8557 return iIn;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8558 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8559
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8560 var s=(iIn+""), a=s.split(""), out="", iLen=s.length;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8561
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8562 for ( var i=0 ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8563 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8564 if ( i%3 === 0 && i !== 0 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8565 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8566 out = this.oLanguage.sInfoThousands+out;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8567
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8568 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8569 out = a[iLen-i-1]+out;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8570 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8571 return out;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8572 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8573
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8574
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8575 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8576 * This function is called on every 'draw' event, and allows you to
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8577 * dynamically modify the header row. This can be used to calculate and
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8578 * display useful information about the table.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8579 * @type function
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8580 * @param {node} nHead "TR" element for the header
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8581 * @param {array} aData Full table data (as derived from the original HTML)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8582 * @param {int} iStart Index for the current display starting point in the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8583 * display array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8584 * @param {int} iEnd Index for the current display ending point in the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8585 * display array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8586 * @param {array int} aiDisplay Index array to translate the visual position
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8587 * to the full data array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8588 * @dtopt Callbacks
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8589 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8590 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8591 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8592 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8593 * "fnHeaderCallback": function( nHead, aData, iStart, iEnd, aiDisplay ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8594 * nHead.getElementsByTagName('th')[0].innerHTML = "Displaying "+(iEnd-iStart)+" records";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8595 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8596 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8597 * } )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8598 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8599 "fnHeaderCallback": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8600
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8601
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8602 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8603 * The information element can be used to convey information about the current
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8604 * state of the table. Although the internationalisation options presented by
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8605 * DataTables are quite capable of dealing with most customisations, there may
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8606 * be times where you wish to customise the string further. This callback
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8607 * allows you to do exactly that.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8608 * @type function
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8609 * @param {object} oSettings DataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8610 * @param {int} iStart Starting position in data for the draw
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8611 * @param {int} iEnd End position in data for the draw
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8612 * @param {int} iMax Total number of rows in the table (regardless of
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8613 * filtering)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8614 * @param {int} iTotal Total number of rows in the data set, after filtering
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8615 * @param {string} sPre The string that DataTables has formatted using it's
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8616 * own rules
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8617 * @returns {string} The string to be displayed in the information element.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8618 * @dtopt Callbacks
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8619 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8620 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8621 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8622 * "fnInfoCallback": function( oSettings, iStart, iEnd, iMax, iTotal, sPre ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8623 * return iStart +" to "+ iEnd;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8624 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8625 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8626 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8627 "fnInfoCallback": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8628
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8629
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8630 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8631 * Called when the table has been initialised. Normally DataTables will
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8632 * initialise sequentially and there will be no need for this function,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8633 * however, this does not hold true when using external language information
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8634 * since that is obtained using an async XHR call.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8635 * @type function
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8636 * @param {object} oSettings DataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8637 * @param {object} json The JSON object request from the server - only
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8638 * present if client-side Ajax sourced data is used
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8639 * @dtopt Callbacks
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8640 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8641 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8642 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8643 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8644 * "fnInitComplete": function(oSettings, json) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8645 * alert( 'DataTables has finished its initialisation.' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8646 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8647 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8648 * } )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8649 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8650 "fnInitComplete": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8651
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8652
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8653 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8654 * Called at the very start of each table draw and can be used to cancel the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8655 * draw by returning false, any other return (including undefined) results in
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8656 * the full draw occurring).
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8657 * @type function
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8658 * @param {object} oSettings DataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8659 * @returns {boolean} False will cancel the draw, anything else (including no
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8660 * return) will allow it to complete.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8661 * @dtopt Callbacks
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8662 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8663 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8664 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8665 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8666 * "fnPreDrawCallback": function( oSettings ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8667 * if ( $('#test').val() == 1 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8668 * return false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8669 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8670 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8671 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8672 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8673 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8674 "fnPreDrawCallback": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8675
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8676
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8677 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8678 * This function allows you to 'post process' each row after it have been
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8679 * generated for each table draw, but before it is rendered on screen. This
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8680 * function might be used for setting the row class name etc.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8681 * @type function
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8682 * @param {node} nRow "TR" element for the current row
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8683 * @param {array} aData Raw data array for this row
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8684 * @param {int} iDisplayIndex The display index for the current table draw
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8685 * @param {int} iDisplayIndexFull The index of the data in the full list of
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8686 * rows (after filtering)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8687 * @dtopt Callbacks
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8688 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8689 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8690 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8691 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8692 * "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8693 * // Bold the grade for all 'A' grade browsers
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8694 * if ( aData[4] == "A" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8695 * {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8696 * $('td:eq(4)', nRow).html( '<b>A</b>' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8697 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8698 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8699 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8700 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8701 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8702 "fnRowCallback": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8703
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8704
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8705 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8706 * This parameter allows you to override the default function which obtains
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8707 * the data from the server ($.getJSON) so something more suitable for your
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8708 * application. For example you could use POST data, or pull information from
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8709 * a Gears or AIR database.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8710 * @type function
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8711 * @member
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8712 * @param {string} sSource HTTP source to obtain the data from (sAjaxSource)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8713 * @param {array} aoData A key/value pair object containing the data to send
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8714 * to the server
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8715 * @param {function} fnCallback to be called on completion of the data get
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8716 * process that will draw the data on the page.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8717 * @param {object} oSettings DataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8718 * @dtopt Callbacks
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8719 * @dtopt Server-side
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8720 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8721 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8722 * // POST data to server
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8723 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8724 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8725 * "bProcessing": true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8726 * "bServerSide": true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8727 * "sAjaxSource": "xhr.php",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8728 * "fnServerData": function ( sSource, aoData, fnCallback, oSettings ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8729 * oSettings.jqXHR = $.ajax( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8730 * "dataType": 'json',
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8731 * "type": "POST",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8732 * "url": sSource,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8733 * "data": aoData,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8734 * "success": fnCallback
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8735 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8736 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8737 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8738 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8739 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8740 "fnServerData": function ( sUrl, aoData, fnCallback, oSettings ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8741 oSettings.jqXHR = $.ajax( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8742 "url": sUrl,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8743 "data": aoData,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8744 "success": function (json) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8745 if ( json.sError ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8746 oSettings.oApi._fnLog( oSettings, 0, json.sError );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8747 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8748
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8749 $(oSettings.oInstance).trigger('xhr', [oSettings, json]);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8750 fnCallback( json );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8751 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8752 "dataType": "json",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8753 "cache": false,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8754 "type": oSettings.sServerMethod,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8755 "error": function (xhr, error, thrown) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8756 if ( error == "parsererror" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8757 oSettings.oApi._fnLog( oSettings, 0, "DataTables warning: JSON data from "+
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8758 "server could not be parsed. This is caused by a JSON formatting error." );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8759 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8760 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8761 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8762 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8763
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8764
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8765 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8766 * It is often useful to send extra data to the server when making an Ajax
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8767 * request - for example custom filtering information, and this callback
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8768 * function makes it trivial to send extra information to the server. The
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8769 * passed in parameter is the data set that has been constructed by
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8770 * DataTables, and you can add to this or modify it as you require.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8771 * @type function
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8772 * @param {array} aoData Data array (array of objects which are name/value
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8773 * pairs) that has been constructed by DataTables and will be sent to the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8774 * server. In the case of Ajax sourced data with server-side processing
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8775 * this will be an empty array, for server-side processing there will be a
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8776 * significant number of parameters!
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8777 * @returns {undefined} Ensure that you modify the aoData array passed in,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8778 * as this is passed by reference.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8779 * @dtopt Callbacks
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8780 * @dtopt Server-side
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8781 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8782 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8783 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8784 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8785 * "bProcessing": true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8786 * "bServerSide": true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8787 * "sAjaxSource": "scripts/server_processing.php",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8788 * "fnServerParams": function ( aoData ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8789 * aoData.push( { "name": "more_data", "value": "my_value" } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8790 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8791 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8792 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8793 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8794 "fnServerParams": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8795
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8796
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8797 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8798 * Load the table state. With this function you can define from where, and how, the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8799 * state of a table is loaded. By default DataTables will load from its state saving
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8800 * cookie, but you might wish to use local storage (HTML5) or a server-side database.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8801 * @type function
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8802 * @member
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8803 * @param {object} oSettings DataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8804 * @return {object} The DataTables state object to be loaded
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8805 * @dtopt Callbacks
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8806 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8807 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8808 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8809 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8810 * "bStateSave": true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8811 * "fnStateLoad": function (oSettings) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8812 * var o;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8813 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8814 * // Send an Ajax request to the server to get the data. Note that
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8815 * // this is a synchronous request.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8816 * $.ajax( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8817 * "url": "/state_load",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8818 * "async": false,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8819 * "dataType": "json",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8820 * "success": function (json) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8821 * o = json;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8822 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8823 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8824 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8825 * return o;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8826 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8827 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8828 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8829 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8830 "fnStateLoad": function ( oSettings ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8831 var sData = this.oApi._fnReadCookie( oSettings.sCookiePrefix+oSettings.sInstance );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8832 var oData;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8833
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8834 try {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8835 oData = (typeof $.parseJSON === 'function') ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8836 $.parseJSON(sData) : eval( '('+sData+')' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8837 } catch (e) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8838 oData = null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8839 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8840
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8841 return oData;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8842 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8843
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8844
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8845 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8846 * Callback which allows modification of the saved state prior to loading that state.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8847 * This callback is called when the table is loading state from the stored data, but
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8848 * prior to the settings object being modified by the saved state. Note that for
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8849 * plug-in authors, you should use the 'stateLoadParams' event to load parameters for
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8850 * a plug-in.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8851 * @type function
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8852 * @param {object} oSettings DataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8853 * @param {object} oData The state object that is to be loaded
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8854 * @dtopt Callbacks
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8855 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8856 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8857 * // Remove a saved filter, so filtering is never loaded
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8858 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8859 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8860 * "bStateSave": true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8861 * "fnStateLoadParams": function (oSettings, oData) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8862 * oData.oSearch.sSearch = "";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8863 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8864 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8865 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8866 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8867 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8868 * // Disallow state loading by returning false
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8869 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8870 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8871 * "bStateSave": true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8872 * "fnStateLoadParams": function (oSettings, oData) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8873 * return false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8874 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8875 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8876 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8877 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8878 "fnStateLoadParams": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8879
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8880
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8881 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8882 * Callback that is called when the state has been loaded from the state saving method
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8883 * and the DataTables settings object has been modified as a result of the loaded state.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8884 * @type function
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8885 * @param {object} oSettings DataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8886 * @param {object} oData The state object that was loaded
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8887 * @dtopt Callbacks
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8888 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8889 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8890 * // Show an alert with the filtering value that was saved
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8891 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8892 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8893 * "bStateSave": true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8894 * "fnStateLoaded": function (oSettings, oData) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8895 * alert( 'Saved filter was: '+oData.oSearch.sSearch );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8896 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8897 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8898 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8899 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8900 "fnStateLoaded": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8901
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8902
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8903 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8904 * Save the table state. This function allows you to define where and how the state
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8905 * information for the table is stored - by default it will use a cookie, but you
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8906 * might want to use local storage (HTML5) or a server-side database.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8907 * @type function
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8908 * @member
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8909 * @param {object} oSettings DataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8910 * @param {object} oData The state object to be saved
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8911 * @dtopt Callbacks
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8912 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8913 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8914 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8915 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8916 * "bStateSave": true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8917 * "fnStateSave": function (oSettings, oData) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8918 * // Send an Ajax request to the server with the state object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8919 * $.ajax( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8920 * "url": "/state_save",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8921 * "data": oData,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8922 * "dataType": "json",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8923 * "method": "POST"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8924 * "success": function () {}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8925 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8926 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8927 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8928 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8929 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8930 "fnStateSave": function ( oSettings, oData ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8931 this.oApi._fnCreateCookie(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8932 oSettings.sCookiePrefix+oSettings.sInstance,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8933 this.oApi._fnJsonString(oData),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8934 oSettings.iCookieDuration,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8935 oSettings.sCookiePrefix,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8936 oSettings.fnCookieCallback
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8937 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8938 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8939
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8940
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8941 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8942 * Callback which allows modification of the state to be saved. Called when the table
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8943 * has changed state a new state save is required. This method allows modification of
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8944 * the state saving object prior to actually doing the save, including addition or
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8945 * other state properties or modification. Note that for plug-in authors, you should
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8946 * use the 'stateSaveParams' event to save parameters for a plug-in.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8947 * @type function
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8948 * @param {object} oSettings DataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8949 * @param {object} oData The state object to be saved
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8950 * @dtopt Callbacks
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8951 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8952 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8953 * // Remove a saved filter, so filtering is never saved
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8954 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8955 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8956 * "bStateSave": true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8957 * "fnStateSaveParams": function (oSettings, oData) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8958 * oData.oSearch.sSearch = "";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8959 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8960 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8961 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8962 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8963 "fnStateSaveParams": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8964
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8965
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8966 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8967 * Duration of the cookie which is used for storing session information. This
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8968 * value is given in seconds.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8969 * @type int
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8970 * @default 7200 <i>(2 hours)</i>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8971 * @dtopt Options
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8972 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8973 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8974 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8975 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8976 * "iCookieDuration": 60*60*24; // 1 day
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8977 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8978 * } )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8979 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8980 "iCookieDuration": 7200,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8981
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8982
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8983 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8984 * When enabled DataTables will not make a request to the server for the first
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8985 * page draw - rather it will use the data already on the page (no sorting etc
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8986 * will be applied to it), thus saving on an XHR at load time. iDeferLoading
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8987 * is used to indicate that deferred loading is required, but it is also used
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8988 * to tell DataTables how many records there are in the full table (allowing
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8989 * the information element and pagination to be displayed correctly). In the case
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8990 * where a filtering is applied to the table on initial load, this can be
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8991 * indicated by giving the parameter as an array, where the first element is
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8992 * the number of records available after filtering and the second element is the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8993 * number of records without filtering (allowing the table information element
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8994 * to be shown correctly).
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8995 * @type int | array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8996 * @default null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8997 * @dtopt Options
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8998 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8999 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9000 * // 57 records available in the table, no filtering applied
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9001 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9002 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9003 * "bServerSide": true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9004 * "sAjaxSource": "scripts/server_processing.php",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9005 * "iDeferLoading": 57
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9006 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9007 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9008 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9009 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9010 * // 57 records after filtering, 100 without filtering (an initial filter applied)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9011 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9012 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9013 * "bServerSide": true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9014 * "sAjaxSource": "scripts/server_processing.php",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9015 * "iDeferLoading": [ 57, 100 ],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9016 * "oSearch": {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9017 * "sSearch": "my_filter"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9018 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9019 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9020 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9021 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9022 "iDeferLoading": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9023
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9024
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9025 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9026 * Number of rows to display on a single page when using pagination. If
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9027 * feature enabled (bLengthChange) then the end user will be able to override
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9028 * this to a custom setting using a pop-up menu.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9029 * @type int
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9030 * @default 10
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9031 * @dtopt Options
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9032 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9033 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9034 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9035 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9036 * "iDisplayLength": 50
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9037 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9038 * } )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9039 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9040 "iDisplayLength": 10,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9041
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9042
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9043 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9044 * Define the starting point for data display when using DataTables with
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9045 * pagination. Note that this parameter is the number of records, rather than
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9046 * the page number, so if you have 10 records per page and want to start on
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9047 * the third page, it should be "20".
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9048 * @type int
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9049 * @default 0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9050 * @dtopt Options
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9051 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9052 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9053 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9054 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9055 * "iDisplayStart": 20
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9056 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9057 * } )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9058 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9059 "iDisplayStart": 0,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9060
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9061
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9062 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9063 * The scroll gap is the amount of scrolling that is left to go before
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9064 * DataTables will load the next 'page' of data automatically. You typically
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9065 * want a gap which is big enough that the scrolling will be smooth for the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9066 * user, while not so large that it will load more data than need.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9067 * @type int
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9068 * @default 100
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9069 * @dtopt Options
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9070 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9071 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9072 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9073 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9074 * "bScrollInfinite": true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9075 * "bScrollCollapse": true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9076 * "sScrollY": "200px",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9077 * "iScrollLoadGap": 50
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9078 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9079 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9080 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9081 "iScrollLoadGap": 100,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9082
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9083
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9084 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9085 * By default DataTables allows keyboard navigation of the table (sorting, paging,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9086 * and filtering) by adding a tabindex attribute to the required elements. This
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9087 * allows you to tab through the controls and press the enter key to activate them.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9088 * The tabindex is default 0, meaning that the tab follows the flow of the document.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9089 * You can overrule this using this parameter if you wish. Use a value of -1 to
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9090 * disable built-in keyboard navigation.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9091 * @type int
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9092 * @default 0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9093 * @dtopt Options
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9094 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9095 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9096 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9097 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9098 * "iTabIndex": 1
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9099 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9100 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9101 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9102 "iTabIndex": 0,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9103
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9104
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9105 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9106 * All strings that DataTables uses in the user interface that it creates
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9107 * are defined in this object, allowing you to modified them individually or
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9108 * completely replace them all as required.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9109 * @namespace
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9110 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9111 "oLanguage": {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9112 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9113 * Strings that are used for WAI-ARIA labels and controls only (these are not
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9114 * actually visible on the page, but will be read by screenreaders, and thus
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9115 * must be internationalised as well).
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9116 * @namespace
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9117 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9118 "oAria": {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9119 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9120 * ARIA label that is added to the table headers when the column may be
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9121 * sorted ascending by activing the column (click or return when focused).
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9122 * Note that the column header is prefixed to this string.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9123 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9124 * @default : activate to sort column ascending
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9125 * @dtopt Language
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9126 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9127 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9128 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9129 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9130 * "oLanguage": {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9131 * "oAria": {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9132 * "sSortAscending": " - click/return to sort ascending"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9133 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9134 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9135 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9136 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9137 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9138 "sSortAscending": ": activate to sort column ascending",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9139
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9140 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9141 * ARIA label that is added to the table headers when the column may be
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9142 * sorted descending by activing the column (click or return when focused).
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9143 * Note that the column header is prefixed to this string.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9144 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9145 * @default : activate to sort column ascending
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9146 * @dtopt Language
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9147 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9148 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9149 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9150 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9151 * "oLanguage": {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9152 * "oAria": {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9153 * "sSortDescending": " - click/return to sort descending"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9154 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9155 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9156 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9157 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9158 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9159 "sSortDescending": ": activate to sort column descending"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9160 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9161
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9162 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9163 * Pagination string used by DataTables for the two built-in pagination
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9164 * control types ("two_button" and "full_numbers")
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9165 * @namespace
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9166 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9167 "oPaginate": {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9168 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9169 * Text to use when using the 'full_numbers' type of pagination for the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9170 * button to take the user to the first page.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9171 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9172 * @default First
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9173 * @dtopt Language
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9174 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9175 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9176 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9177 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9178 * "oLanguage": {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9179 * "oPaginate": {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9180 * "sFirst": "First page"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9181 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9182 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9183 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9184 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9185 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9186 "sFirst": "First",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9187
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9188
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9189 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9190 * Text to use when using the 'full_numbers' type of pagination for the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9191 * button to take the user to the last page.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9192 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9193 * @default Last
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9194 * @dtopt Language
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9195 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9196 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9197 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9198 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9199 * "oLanguage": {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9200 * "oPaginate": {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9201 * "sLast": "Last page"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9202 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9203 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9204 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9205 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9206 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9207 "sLast": "Last",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9208
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9209
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9210 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9211 * Text to use for the 'next' pagination button (to take the user to the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9212 * next page).
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9213 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9214 * @default Next
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9215 * @dtopt Language
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9216 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9217 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9218 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9219 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9220 * "oLanguage": {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9221 * "oPaginate": {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9222 * "sNext": "Next page"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9223 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9224 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9225 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9226 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9227 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9228 "sNext": "Next",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9229
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9230
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9231 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9232 * Text to use for the 'previous' pagination button (to take the user to
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9233 * the previous page).
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9234 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9235 * @default Previous
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9236 * @dtopt Language
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9237 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9238 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9239 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9240 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9241 * "oLanguage": {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9242 * "oPaginate": {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9243 * "sPrevious": "Previous page"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9244 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9245 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9246 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9247 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9248 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9249 "sPrevious": "Previous"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9250 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9251
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9252 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9253 * This string is shown in preference to sZeroRecords when the table is
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9254 * empty of data (regardless of filtering). Note that this is an optional
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9255 * parameter - if it is not given, the value of sZeroRecords will be used
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9256 * instead (either the default or given value).
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9257 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9258 * @default No data available in table
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9259 * @dtopt Language
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9260 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9261 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9262 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9263 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9264 * "oLanguage": {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9265 * "sEmptyTable": "No data available in table"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9266 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9267 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9268 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9269 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9270 "sEmptyTable": "No data available in table",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9271
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9272
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9273 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9274 * This string gives information to the end user about the information that
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9275 * is current on display on the page. The _START_, _END_ and _TOTAL_
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9276 * variables are all dynamically replaced as the table display updates, and
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9277 * can be freely moved or removed as the language requirements change.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9278 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9279 * @default Showing _START_ to _END_ of _TOTAL_ entries
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9280 * @dtopt Language
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9281 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9282 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9283 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9284 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9285 * "oLanguage": {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9286 * "sInfo": "Got a total of _TOTAL_ entries to show (_START_ to _END_)"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9287 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9288 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9289 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9290 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9291 "sInfo": "Showing _START_ to _END_ of _TOTAL_ entries",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9292
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9293
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9294 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9295 * Display information string for when the table is empty. Typically the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9296 * format of this string should match sInfo.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9297 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9298 * @default Showing 0 to 0 of 0 entries
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9299 * @dtopt Language
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9300 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9301 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9302 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9303 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9304 * "oLanguage": {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9305 * "sInfoEmpty": "No entries to show"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9306 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9307 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9308 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9309 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9310 "sInfoEmpty": "Showing 0 to 0 of 0 entries",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9311
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9312
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9313 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9314 * When a user filters the information in a table, this string is appended
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9315 * to the information (sInfo) to give an idea of how strong the filtering
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9316 * is. The variable _MAX_ is dynamically updated.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9317 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9318 * @default (filtered from _MAX_ total entries)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9319 * @dtopt Language
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9320 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9321 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9322 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9323 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9324 * "oLanguage": {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9325 * "sInfoFiltered": " - filtering from _MAX_ records"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9326 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9327 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9328 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9329 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9330 "sInfoFiltered": "(filtered from _MAX_ total entries)",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9331
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9332
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9333 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9334 * If can be useful to append extra information to the info string at times,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9335 * and this variable does exactly that. This information will be appended to
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9336 * the sInfo (sInfoEmpty and sInfoFiltered in whatever combination they are
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9337 * being used) at all times.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9338 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9339 * @default <i>Empty string</i>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9340 * @dtopt Language
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9341 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9342 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9343 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9344 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9345 * "oLanguage": {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9346 * "sInfoPostFix": "All records shown are derived from real information."
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9347 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9348 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9349 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9350 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9351 "sInfoPostFix": "",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9352
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9353
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9354 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9355 * DataTables has a build in number formatter (fnFormatNumber) which is used
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9356 * to format large numbers that are used in the table information. By
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9357 * default a comma is used, but this can be trivially changed to any
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9358 * character you wish with this parameter.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9359 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9360 * @default ,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9361 * @dtopt Language
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9362 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9363 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9364 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9365 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9366 * "oLanguage": {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9367 * "sInfoThousands": "'"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9368 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9369 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9370 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9371 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9372 "sInfoThousands": ",",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9373
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9374
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9375 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9376 * Detail the action that will be taken when the drop down menu for the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9377 * pagination length option is changed. The '_MENU_' variable is replaced
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9378 * with a default select list of 10, 25, 50 and 100, and can be replaced
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9379 * with a custom select box if required.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9380 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9381 * @default Show _MENU_ entries
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9382 * @dtopt Language
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9383 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9384 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9385 * // Language change only
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9386 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9387 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9388 * "oLanguage": {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9389 * "sLengthMenu": "Display _MENU_ records"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9390 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9391 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9392 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9393 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9394 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9395 * // Language and options change
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9396 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9397 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9398 * "oLanguage": {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9399 * "sLengthMenu": 'Display <select>'+
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9400 * '<option value="10">10</option>'+
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9401 * '<option value="20">20</option>'+
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9402 * '<option value="30">30</option>'+
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9403 * '<option value="40">40</option>'+
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9404 * '<option value="50">50</option>'+
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9405 * '<option value="-1">All</option>'+
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9406 * '</select> records'
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9407 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9408 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9409 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9410 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9411 "sLengthMenu": "Show _MENU_ entries",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9412
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9413
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9414 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9415 * When using Ajax sourced data and during the first draw when DataTables is
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9416 * gathering the data, this message is shown in an empty row in the table to
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9417 * indicate to the end user the the data is being loaded. Note that this
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9418 * parameter is not used when loading data by server-side processing, just
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9419 * Ajax sourced data with client-side processing.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9420 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9421 * @default Loading...
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9422 * @dtopt Language
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9423 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9424 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9425 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9426 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9427 * "oLanguage": {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9428 * "sLoadingRecords": "Please wait - loading..."
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9429 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9430 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9431 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9432 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9433 "sLoadingRecords": "Loading...",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9434
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9435
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9436 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9437 * Text which is displayed when the table is processing a user action
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9438 * (usually a sort command or similar).
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9439 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9440 * @default Processing...
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9441 * @dtopt Language
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9442 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9443 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9444 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9445 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9446 * "oLanguage": {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9447 * "sProcessing": "DataTables is currently busy"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9448 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9449 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9450 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9451 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9452 "sProcessing": "Processing...",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9453
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9454
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9455 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9456 * Details the actions that will be taken when the user types into the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9457 * filtering input text box. The variable "_INPUT_", if used in the string,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9458 * is replaced with the HTML text box for the filtering input allowing
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9459 * control over where it appears in the string. If "_INPUT_" is not given
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9460 * then the input box is appended to the string automatically.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9461 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9462 * @default Search:
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9463 * @dtopt Language
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9464 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9465 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9466 * // Input text box will be appended at the end automatically
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9467 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9468 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9469 * "oLanguage": {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9470 * "sSearch": "Filter records:"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9471 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9472 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9473 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9474 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9475 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9476 * // Specify where the filter should appear
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9477 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9478 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9479 * "oLanguage": {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9480 * "sSearch": "Apply filter _INPUT_ to table"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9481 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9482 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9483 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9484 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9485 "sSearch": "Search:",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9486
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9487
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9488 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9489 * All of the language information can be stored in a file on the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9490 * server-side, which DataTables will look up if this parameter is passed.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9491 * It must store the URL of the language file, which is in a JSON format,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9492 * and the object has the same properties as the oLanguage object in the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9493 * initialiser object (i.e. the above parameters). Please refer to one of
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9494 * the example language files to see how this works in action.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9495 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9496 * @default <i>Empty string - i.e. disabled</i>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9497 * @dtopt Language
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9498 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9499 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9500 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9501 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9502 * "oLanguage": {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9503 * "sUrl": "http://www.sprymedia.co.uk/dataTables/lang.txt"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9504 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9505 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9506 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9507 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9508 "sUrl": "",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9509
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9510
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9511 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9512 * Text shown inside the table records when the is no information to be
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9513 * displayed after filtering. sEmptyTable is shown when there is simply no
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9514 * information in the table at all (regardless of filtering).
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9515 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9516 * @default No matching records found
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9517 * @dtopt Language
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9518 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9519 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9520 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9521 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9522 * "oLanguage": {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9523 * "sZeroRecords": "No records to display"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9524 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9525 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9526 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9527 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9528 "sZeroRecords": "No matching records found"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9529 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9530
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9531
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9532 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9533 * This parameter allows you to have define the global filtering state at
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9534 * initialisation time. As an object the "sSearch" parameter must be
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9535 * defined, but all other parameters are optional. When "bRegex" is true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9536 * the search string will be treated as a regular expression, when false
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9537 * (default) it will be treated as a straight string. When "bSmart"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9538 * DataTables will use it's smart filtering methods (to word match at
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9539 * any point in the data), when false this will not be done.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9540 * @namespace
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9541 * @extends DataTable.models.oSearch
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9542 * @dtopt Options
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9543 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9544 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9545 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9546 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9547 * "oSearch": {"sSearch": "Initial search"}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9548 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9549 * } )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9550 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9551 "oSearch": $.extend( {}, DataTable.models.oSearch ),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9552
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9553
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9554 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9555 * By default DataTables will look for the property 'aaData' when obtaining
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9556 * data from an Ajax source or for server-side processing - this parameter
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9557 * allows that property to be changed. You can use Javascript dotted object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9558 * notation to get a data source for multiple levels of nesting.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9559 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9560 * @default aaData
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9561 * @dtopt Options
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9562 * @dtopt Server-side
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9563 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9564 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9565 * // Get data from { "data": [...] }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9566 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9567 * var oTable = $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9568 * "sAjaxSource": "sources/data.txt",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9569 * "sAjaxDataProp": "data"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9570 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9571 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9572 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9573 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9574 * // Get data from { "data": { "inner": [...] } }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9575 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9576 * var oTable = $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9577 * "sAjaxSource": "sources/data.txt",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9578 * "sAjaxDataProp": "data.inner"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9579 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9580 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9581 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9582 "sAjaxDataProp": "aaData",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9583
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9584
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9585 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9586 * You can instruct DataTables to load data from an external source using this
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9587 * parameter (use aData if you want to pass data in you already have). Simply
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9588 * provide a url a JSON object can be obtained from. This object must include
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9589 * the parameter 'aaData' which is the data source for the table.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9590 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9591 * @default null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9592 * @dtopt Options
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9593 * @dtopt Server-side
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9594 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9595 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9596 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9597 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9598 * "sAjaxSource": "http://www.sprymedia.co.uk/dataTables/json.php"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9599 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9600 * } )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9601 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9602 "sAjaxSource": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9603
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9604
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9605 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9606 * This parameter can be used to override the default prefix that DataTables
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9607 * assigns to a cookie when state saving is enabled.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9608 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9609 * @default SpryMedia_DataTables_
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9610 * @dtopt Options
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9611 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9612 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9613 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9614 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9615 * "sCookiePrefix": "my_datatable_",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9616 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9617 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9618 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9619 "sCookiePrefix": "SpryMedia_DataTables_",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9620
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9621
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9622 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9623 * This initialisation variable allows you to specify exactly where in the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9624 * DOM you want DataTables to inject the various controls it adds to the page
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9625 * (for example you might want the pagination controls at the top of the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9626 * table). DIV elements (with or without a custom class) can also be added to
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9627 * aid styling. The follow syntax is used:
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9628 * <ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9629 * <li>The following options are allowed:
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9630 * <ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9631 * <li>'l' - Length changing</li
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9632 * <li>'f' - Filtering input</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9633 * <li>'t' - The table!</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9634 * <li>'i' - Information</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9635 * <li>'p' - Pagination</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9636 * <li>'r' - pRocessing</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9637 * </ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9638 * </li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9639 * <li>The following constants are allowed:
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9640 * <ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9641 * <li>'H' - jQueryUI theme "header" classes ('fg-toolbar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix')</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9642 * <li>'F' - jQueryUI theme "footer" classes ('fg-toolbar ui-widget-header ui-corner-bl ui-corner-br ui-helper-clearfix')</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9643 * </ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9644 * </li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9645 * <li>The following syntax is expected:
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9646 * <ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9647 * <li>'&lt;' and '&gt;' - div elements</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9648 * <li>'&lt;"class" and '&gt;' - div with a class</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9649 * <li>'&lt;"#id" and '&gt;' - div with an ID</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9650 * </ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9651 * </li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9652 * <li>Examples:
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9653 * <ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9654 * <li>'&lt;"wrapper"flipt&gt;'</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9655 * <li>'&lt;lf&lt;t&gt;ip&gt;'</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9656 * </ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9657 * </li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9658 * </ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9659 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9660 * @default lfrtip <i>(when bJQueryUI is false)</i> <b>or</b>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9661 * <"H"lfr>t<"F"ip> <i>(when bJQueryUI is true)</i>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9662 * @dtopt Options
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9663 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9664 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9665 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9666 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9667 * "sDom": '&lt;"top"i&gt;rt&lt;"bottom"flp&gt;&lt;"clear"&gt;'
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9668 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9669 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9670 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9671 "sDom": "lfrtip",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9672
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9673
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9674 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9675 * DataTables features two different built-in pagination interaction methods
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9676 * ('two_button' or 'full_numbers') which present different page controls to
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9677 * the end user. Further methods can be added using the API (see below).
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9678 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9679 * @default two_button
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9680 * @dtopt Options
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9681 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9682 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9683 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9684 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9685 * "sPaginationType": "full_numbers"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9686 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9687 * } )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9688 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9689 "sPaginationType": "two_button",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9690
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9691
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9692 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9693 * Enable horizontal scrolling. When a table is too wide to fit into a certain
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9694 * layout, or you have a large number of columns in the table, you can enable
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9695 * x-scrolling to show the table in a viewport, which can be scrolled. This
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9696 * property can be any CSS unit, or a number (in which case it will be treated
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9697 * as a pixel measurement).
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9698 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9699 * @default <i>blank string - i.e. disabled</i>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9700 * @dtopt Features
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9701 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9702 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9703 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9704 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9705 * "sScrollX": "100%",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9706 * "bScrollCollapse": true
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9707 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9708 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9709 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9710 "sScrollX": "",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9711
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9712
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9713 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9714 * This property can be used to force a DataTable to use more width than it
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9715 * might otherwise do when x-scrolling is enabled. For example if you have a
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9716 * table which requires to be well spaced, this parameter is useful for
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9717 * "over-sizing" the table, and thus forcing scrolling. This property can by
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9718 * any CSS unit, or a number (in which case it will be treated as a pixel
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9719 * measurement).
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9720 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9721 * @default <i>blank string - i.e. disabled</i>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9722 * @dtopt Options
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9723 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9724 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9725 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9726 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9727 * "sScrollX": "100%",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9728 * "sScrollXInner": "110%"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9729 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9730 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9731 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9732 "sScrollXInner": "",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9733
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9734
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9735 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9736 * Enable vertical scrolling. Vertical scrolling will constrain the DataTable
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9737 * to the given height, and enable scrolling for any data which overflows the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9738 * current viewport. This can be used as an alternative to paging to display
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9739 * a lot of data in a small area (although paging and scrolling can both be
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9740 * enabled at the same time). This property can be any CSS unit, or a number
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9741 * (in which case it will be treated as a pixel measurement).
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9742 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9743 * @default <i>blank string - i.e. disabled</i>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9744 * @dtopt Features
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9745 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9746 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9747 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9748 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9749 * "sScrollY": "200px",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9750 * "bPaginate": false
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9751 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9752 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9753 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9754 "sScrollY": "",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9755
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9756
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9757 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9758 * Set the HTTP method that is used to make the Ajax call for server-side
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9759 * processing or Ajax sourced data.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9760 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9761 * @default GET
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9762 * @dtopt Options
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9763 * @dtopt Server-side
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9764 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9765 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9766 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9767 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9768 * "bServerSide": true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9769 * "sAjaxSource": "scripts/post.php",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9770 * "sServerMethod": "POST"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9771 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9772 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9773 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9774 "sServerMethod": "GET"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9775 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9776
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9777
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9778
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9779 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9780 * Column options that can be given to DataTables at initialisation time.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9781 * @namespace
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9782 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9783 DataTable.defaults.columns = {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9784 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9785 * Allows a column's sorting to take multiple columns into account when
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9786 * doing a sort. For example first name / last name columns make sense to
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9787 * do a multi-column sort over the two columns.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9788 * @type array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9789 * @default null <i>Takes the value of the column index automatically</i>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9790 * @dtopt Columns
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9791 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9792 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9793 * // Using aoColumnDefs
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9794 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9795 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9796 * "aoColumnDefs": [
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9797 * { "aDataSort": [ 0, 1 ], "aTargets": [ 0 ] },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9798 * { "aDataSort": [ 1, 0 ], "aTargets": [ 1 ] },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9799 * { "aDataSort": [ 2, 3, 4 ], "aTargets": [ 2 ] }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9800 * ]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9801 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9802 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9803 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9804 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9805 * // Using aoColumns
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9806 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9807 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9808 * "aoColumns": [
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9809 * { "aDataSort": [ 0, 1 ] },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9810 * { "aDataSort": [ 1, 0 ] },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9811 * { "aDataSort": [ 2, 3, 4 ] },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9812 * null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9813 * null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9814 * ]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9815 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9816 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9817 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9818 "aDataSort": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9819
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9820
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9821 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9822 * You can control the default sorting direction, and even alter the behaviour
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9823 * of the sort handler (i.e. only allow ascending sorting etc) using this
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9824 * parameter.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9825 * @type array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9826 * @default [ 'asc', 'desc' ]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9827 * @dtopt Columns
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9828 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9829 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9830 * // Using aoColumnDefs
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9831 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9832 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9833 * "aoColumnDefs": [
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9834 * { "asSorting": [ "asc" ], "aTargets": [ 1 ] },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9835 * { "asSorting": [ "desc", "asc", "asc" ], "aTargets": [ 2 ] },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9836 * { "asSorting": [ "desc" ], "aTargets": [ 3 ] }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9837 * ]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9838 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9839 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9840 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9841 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9842 * // Using aoColumns
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9843 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9844 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9845 * "aoColumns": [
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9846 * null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9847 * { "asSorting": [ "asc" ] },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9848 * { "asSorting": [ "desc", "asc", "asc" ] },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9849 * { "asSorting": [ "desc" ] },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9850 * null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9851 * ]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9852 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9853 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9854 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9855 "asSorting": [ 'asc', 'desc' ],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9856
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9857
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9858 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9859 * Enable or disable filtering on the data in this column.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9860 * @type boolean
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9861 * @default true
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9862 * @dtopt Columns
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9863 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9864 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9865 * // Using aoColumnDefs
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9866 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9867 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9868 * "aoColumnDefs": [
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9869 * { "bSearchable": false, "aTargets": [ 0 ] }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9870 * ] } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9871 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9872 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9873 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9874 * // Using aoColumns
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9875 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9876 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9877 * "aoColumns": [
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9878 * { "bSearchable": false },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9879 * null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9880 * null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9881 * null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9882 * null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9883 * ] } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9884 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9885 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9886 "bSearchable": true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9887
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9888
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9889 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9890 * Enable or disable sorting on this column.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9891 * @type boolean
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9892 * @default true
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9893 * @dtopt Columns
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9894 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9895 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9896 * // Using aoColumnDefs
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9897 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9898 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9899 * "aoColumnDefs": [
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9900 * { "bSortable": false, "aTargets": [ 0 ] }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9901 * ] } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9902 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9903 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9904 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9905 * // Using aoColumns
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9906 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9907 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9908 * "aoColumns": [
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9909 * { "bSortable": false },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9910 * null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9911 * null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9912 * null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9913 * null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9914 * ] } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9915 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9916 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9917 "bSortable": true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9918
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9919
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9920 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9921 * <code>Deprecated</code> When using fnRender() for a column, you may wish
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9922 * to use the original data (before rendering) for sorting and filtering
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9923 * (the default is to used the rendered data that the user can see). This
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9924 * may be useful for dates etc.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9925 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9926 * Please note that this option has now been deprecated and will be removed
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9927 * in the next version of DataTables. Please use mRender / mData rather than
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9928 * fnRender.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9929 * @type boolean
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9930 * @default true
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9931 * @dtopt Columns
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9932 * @deprecated
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9933 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9934 "bUseRendered": true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9935
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9936
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9937 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9938 * Enable or disable the display of this column.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9939 * @type boolean
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9940 * @default true
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9941 * @dtopt Columns
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9942 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9943 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9944 * // Using aoColumnDefs
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9945 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9946 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9947 * "aoColumnDefs": [
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9948 * { "bVisible": false, "aTargets": [ 0 ] }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9949 * ] } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9950 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9951 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9952 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9953 * // Using aoColumns
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9954 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9955 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9956 * "aoColumns": [
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9957 * { "bVisible": false },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9958 * null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9959 * null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9960 * null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9961 * null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9962 * ] } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9963 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9964 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9965 "bVisible": true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9966
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9967
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9968 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9969 * Developer definable function that is called whenever a cell is created (Ajax source,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9970 * etc) or processed for input (DOM source). This can be used as a compliment to mRender
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9971 * allowing you to modify the DOM element (add background colour for example) when the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9972 * element is available.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9973 * @type function
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9974 * @param {element} nTd The TD node that has been created
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9975 * @param {*} sData The Data for the cell
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9976 * @param {array|object} oData The data for the whole row
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9977 * @param {int} iRow The row index for the aoData data store
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9978 * @param {int} iCol The column index for aoColumns
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9979 * @dtopt Columns
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9980 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9981 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9982 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9983 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9984 * "aoColumnDefs": [ {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9985 * "aTargets": [3],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9986 * "fnCreatedCell": function (nTd, sData, oData, iRow, iCol) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9987 * if ( sData == "1.7" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9988 * $(nTd).css('color', 'blue')
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9989 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9990 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9991 * } ]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9992 * });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9993 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9994 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9995 "fnCreatedCell": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9996
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9997
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9998 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9999 * <code>Deprecated</code> Custom display function that will be called for the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10000 * display of each cell in this column.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10001 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10002 * Please note that this option has now been deprecated and will be removed
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10003 * in the next version of DataTables. Please use mRender / mData rather than
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10004 * fnRender.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10005 * @type function
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10006 * @param {object} o Object with the following parameters:
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10007 * @param {int} o.iDataRow The row in aoData
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10008 * @param {int} o.iDataColumn The column in question
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10009 * @param {array} o.aData The data for the row in question
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10010 * @param {object} o.oSettings The settings object for this DataTables instance
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10011 * @param {object} o.mDataProp The data property used for this column
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10012 * @param {*} val The current cell value
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10013 * @returns {string} The string you which to use in the display
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10014 * @dtopt Columns
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10015 * @deprecated
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10016 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10017 "fnRender": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10018
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10019
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10020 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10021 * The column index (starting from 0!) that you wish a sort to be performed
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10022 * upon when this column is selected for sorting. This can be used for sorting
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10023 * on hidden columns for example.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10024 * @type int
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10025 * @default -1 <i>Use automatically calculated column index</i>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10026 * @dtopt Columns
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10027 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10028 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10029 * // Using aoColumnDefs
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10030 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10031 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10032 * "aoColumnDefs": [
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10033 * { "iDataSort": 1, "aTargets": [ 0 ] }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10034 * ]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10035 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10036 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10037 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10038 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10039 * // Using aoColumns
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10040 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10041 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10042 * "aoColumns": [
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10043 * { "iDataSort": 1 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10044 * null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10045 * null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10046 * null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10047 * null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10048 * ]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10049 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10050 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10051 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10052 "iDataSort": -1,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10053
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10054
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10055 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10056 * This parameter has been replaced by mData in DataTables to ensure naming
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10057 * consistency. mDataProp can still be used, as there is backwards compatibility
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10058 * in DataTables for this option, but it is strongly recommended that you use
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10059 * mData in preference to mDataProp.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10060 * @name DataTable.defaults.columns.mDataProp
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10061 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10062
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10063
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10064 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10065 * This property can be used to read data from any JSON data source property,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10066 * including deeply nested objects / properties. mData can be given in a
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10067 * number of different ways which effect its behaviour:
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10068 * <ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10069 * <li>integer - treated as an array index for the data source. This is the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10070 * default that DataTables uses (incrementally increased for each column).</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10071 * <li>string - read an object property from the data source. Note that you can
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10072 * use Javascript dotted notation to read deep properties / arrays from the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10073 * data source.</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10074 * <li>null - the sDefaultContent option will be used for the cell (null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10075 * by default, so you will need to specify the default content you want -
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10076 * typically an empty string). This can be useful on generated columns such
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10077 * as edit / delete action columns.</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10078 * <li>function - the function given will be executed whenever DataTables
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10079 * needs to set or get the data for a cell in the column. The function
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10080 * takes three parameters:
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10081 * <ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10082 * <li>{array|object} The data source for the row</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10083 * <li>{string} The type call data requested - this will be 'set' when
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10084 * setting data or 'filter', 'display', 'type', 'sort' or undefined when
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10085 * gathering data. Note that when <i>undefined</i> is given for the type
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10086 * DataTables expects to get the raw data for the object back</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10087 * <li>{*} Data to set when the second parameter is 'set'.</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10088 * </ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10089 * The return value from the function is not required when 'set' is the type
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10090 * of call, but otherwise the return is what will be used for the data
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10091 * requested.</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10092 * </ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10093 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10094 * Note that prior to DataTables 1.9.2 mData was called mDataProp. The name change
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10095 * reflects the flexibility of this property and is consistent with the naming of
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10096 * mRender. If 'mDataProp' is given, then it will still be used by DataTables, as
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10097 * it automatically maps the old name to the new if required.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10098 * @type string|int|function|null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10099 * @default null <i>Use automatically calculated column index</i>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10100 * @dtopt Columns
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10101 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10102 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10103 * // Read table data from objects
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10104 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10105 * var oTable = $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10106 * "sAjaxSource": "sources/deep.txt",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10107 * "aoColumns": [
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10108 * { "mData": "engine" },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10109 * { "mData": "browser" },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10110 * { "mData": "platform.inner" },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10111 * { "mData": "platform.details.0" },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10112 * { "mData": "platform.details.1" }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10113 * ]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10114 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10115 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10116 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10117 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10118 * // Using mData as a function to provide different information for
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10119 * // sorting, filtering and display. In this case, currency (price)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10120 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10121 * var oTable = $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10122 * "aoColumnDefs": [ {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10123 * "aTargets": [ 0 ],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10124 * "mData": function ( source, type, val ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10125 * if (type === 'set') {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10126 * source.price = val;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10127 * // Store the computed dislay and filter values for efficiency
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10128 * source.price_display = val=="" ? "" : "$"+numberFormat(val);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10129 * source.price_filter = val=="" ? "" : "$"+numberFormat(val)+" "+val;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10130 * return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10131 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10132 * else if (type === 'display') {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10133 * return source.price_display;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10134 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10135 * else if (type === 'filter') {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10136 * return source.price_filter;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10137 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10138 * // 'sort', 'type' and undefined all just use the integer
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10139 * return source.price;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10140 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10141 * } ]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10142 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10143 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10144 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10145 "mData": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10146
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10147
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10148 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10149 * This property is the rendering partner to mData and it is suggested that
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10150 * when you want to manipulate data for display (including filtering, sorting etc)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10151 * but not altering the underlying data for the table, use this property. mData
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10152 * can actually do everything this property can and more, but this parameter is
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10153 * easier to use since there is no 'set' option. Like mData is can be given
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10154 * in a number of different ways to effect its behaviour, with the addition of
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10155 * supporting array syntax for easy outputting of arrays (including arrays of
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10156 * objects):
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10157 * <ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10158 * <li>integer - treated as an array index for the data source. This is the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10159 * default that DataTables uses (incrementally increased for each column).</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10160 * <li>string - read an object property from the data source. Note that you can
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10161 * use Javascript dotted notation to read deep properties / arrays from the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10162 * data source and also array brackets to indicate that the data reader should
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10163 * loop over the data source array. When characters are given between the array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10164 * brackets, these characters are used to join the data source array together.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10165 * For example: "accounts[, ].name" would result in a comma separated list with
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10166 * the 'name' value from the 'accounts' array of objects.</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10167 * <li>function - the function given will be executed whenever DataTables
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10168 * needs to set or get the data for a cell in the column. The function
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10169 * takes three parameters:
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10170 * <ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10171 * <li>{array|object} The data source for the row (based on mData)</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10172 * <li>{string} The type call data requested - this will be 'filter', 'display',
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10173 * 'type' or 'sort'.</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10174 * <li>{array|object} The full data source for the row (not based on mData)</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10175 * </ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10176 * The return value from the function is what will be used for the data
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10177 * requested.</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10178 * </ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10179 * @type string|int|function|null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10180 * @default null <i>Use mData</i>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10181 * @dtopt Columns
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10182 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10183 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10184 * // Create a comma separated list from an array of objects
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10185 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10186 * var oTable = $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10187 * "sAjaxSource": "sources/deep.txt",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10188 * "aoColumns": [
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10189 * { "mData": "engine" },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10190 * { "mData": "browser" },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10191 * {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10192 * "mData": "platform",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10193 * "mRender": "[, ].name"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10194 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10195 * ]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10196 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10197 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10198 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10199 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10200 * // Use as a function to create a link from the data source
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10201 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10202 * var oTable = $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10203 * "aoColumnDefs": [
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10204 * {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10205 * "aTargets": [ 0 ],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10206 * "mData": "download_link",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10207 * "mRender": function ( data, type, full ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10208 * return '<a href="'+data+'">Download</a>';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10209 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10210 * ]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10211 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10212 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10213 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10214 "mRender": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10215
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10216
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10217 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10218 * Change the cell type created for the column - either TD cells or TH cells. This
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10219 * can be useful as TH cells have semantic meaning in the table body, allowing them
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10220 * to act as a header for a row (you may wish to add scope='row' to the TH elements).
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10221 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10222 * @default td
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10223 * @dtopt Columns
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10224 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10225 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10226 * // Make the first column use TH cells
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10227 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10228 * var oTable = $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10229 * "aoColumnDefs": [ {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10230 * "aTargets": [ 0 ],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10231 * "sCellType": "th"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10232 * } ]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10233 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10234 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10235 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10236 "sCellType": "td",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10237
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10238
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10239 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10240 * Class to give to each cell in this column.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10241 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10242 * @default <i>Empty string</i>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10243 * @dtopt Columns
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10244 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10245 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10246 * // Using aoColumnDefs
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10247 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10248 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10249 * "aoColumnDefs": [
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10250 * { "sClass": "my_class", "aTargets": [ 0 ] }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10251 * ]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10252 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10253 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10254 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10255 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10256 * // Using aoColumns
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10257 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10258 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10259 * "aoColumns": [
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10260 * { "sClass": "my_class" },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10261 * null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10262 * null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10263 * null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10264 * null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10265 * ]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10266 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10267 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10268 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10269 "sClass": "",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10270
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10271 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10272 * When DataTables calculates the column widths to assign to each column,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10273 * it finds the longest string in each column and then constructs a
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10274 * temporary table and reads the widths from that. The problem with this
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10275 * is that "mmm" is much wider then "iiii", but the latter is a longer
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10276 * string - thus the calculation can go wrong (doing it properly and putting
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10277 * it into an DOM object and measuring that is horribly(!) slow). Thus as
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10278 * a "work around" we provide this option. It will append its value to the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10279 * text that is found to be the longest string for the column - i.e. padding.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10280 * Generally you shouldn't need this, and it is not documented on the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10281 * general DataTables.net documentation
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10282 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10283 * @default <i>Empty string<i>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10284 * @dtopt Columns
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10285 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10286 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10287 * // Using aoColumns
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10288 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10289 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10290 * "aoColumns": [
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10291 * null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10292 * null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10293 * null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10294 * {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10295 * "sContentPadding": "mmm"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10296 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10297 * ]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10298 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10299 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10300 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10301 "sContentPadding": "",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10302
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10303
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10304 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10305 * Allows a default value to be given for a column's data, and will be used
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10306 * whenever a null data source is encountered (this can be because mData
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10307 * is set to null, or because the data source itself is null).
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10308 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10309 * @default null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10310 * @dtopt Columns
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10311 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10312 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10313 * // Using aoColumnDefs
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10314 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10315 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10316 * "aoColumnDefs": [
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10317 * {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10318 * "mData": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10319 * "sDefaultContent": "Edit",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10320 * "aTargets": [ -1 ]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10321 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10322 * ]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10323 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10324 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10325 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10326 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10327 * // Using aoColumns
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10328 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10329 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10330 * "aoColumns": [
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10331 * null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10332 * null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10333 * null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10334 * {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10335 * "mData": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10336 * "sDefaultContent": "Edit"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10337 * }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10338 * ]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10339 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10340 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10341 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10342 "sDefaultContent": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10343
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10344
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10345 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10346 * This parameter is only used in DataTables' server-side processing. It can
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10347 * be exceptionally useful to know what columns are being displayed on the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10348 * client side, and to map these to database fields. When defined, the names
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10349 * also allow DataTables to reorder information from the server if it comes
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10350 * back in an unexpected order (i.e. if you switch your columns around on the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10351 * client-side, your server-side code does not also need updating).
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10352 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10353 * @default <i>Empty string</i>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10354 * @dtopt Columns
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10355 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10356 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10357 * // Using aoColumnDefs
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10358 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10359 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10360 * "aoColumnDefs": [
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10361 * { "sName": "engine", "aTargets": [ 0 ] },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10362 * { "sName": "browser", "aTargets": [ 1 ] },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10363 * { "sName": "platform", "aTargets": [ 2 ] },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10364 * { "sName": "version", "aTargets": [ 3 ] },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10365 * { "sName": "grade", "aTargets": [ 4 ] }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10366 * ]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10367 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10368 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10369 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10370 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10371 * // Using aoColumns
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10372 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10373 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10374 * "aoColumns": [
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10375 * { "sName": "engine" },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10376 * { "sName": "browser" },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10377 * { "sName": "platform" },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10378 * { "sName": "version" },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10379 * { "sName": "grade" }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10380 * ]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10381 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10382 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10383 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10384 "sName": "",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10385
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10386
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10387 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10388 * Defines a data source type for the sorting which can be used to read
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10389 * real-time information from the table (updating the internally cached
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10390 * version) prior to sorting. This allows sorting to occur on user editable
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10391 * elements such as form inputs.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10392 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10393 * @default std
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10394 * @dtopt Columns
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10395 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10396 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10397 * // Using aoColumnDefs
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10398 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10399 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10400 * "aoColumnDefs": [
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10401 * { "sSortDataType": "dom-text", "aTargets": [ 2, 3 ] },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10402 * { "sType": "numeric", "aTargets": [ 3 ] },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10403 * { "sSortDataType": "dom-select", "aTargets": [ 4 ] },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10404 * { "sSortDataType": "dom-checkbox", "aTargets": [ 5 ] }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10405 * ]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10406 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10407 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10408 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10409 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10410 * // Using aoColumns
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10411 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10412 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10413 * "aoColumns": [
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10414 * null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10415 * null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10416 * { "sSortDataType": "dom-text" },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10417 * { "sSortDataType": "dom-text", "sType": "numeric" },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10418 * { "sSortDataType": "dom-select" },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10419 * { "sSortDataType": "dom-checkbox" }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10420 * ]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10421 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10422 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10423 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10424 "sSortDataType": "std",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10425
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10426
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10427 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10428 * The title of this column.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10429 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10430 * @default null <i>Derived from the 'TH' value for this column in the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10431 * original HTML table.</i>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10432 * @dtopt Columns
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10433 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10434 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10435 * // Using aoColumnDefs
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10436 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10437 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10438 * "aoColumnDefs": [
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10439 * { "sTitle": "My column title", "aTargets": [ 0 ] }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10440 * ]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10441 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10442 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10443 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10444 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10445 * // Using aoColumns
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10446 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10447 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10448 * "aoColumns": [
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10449 * { "sTitle": "My column title" },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10450 * null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10451 * null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10452 * null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10453 * null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10454 * ]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10455 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10456 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10457 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10458 "sTitle": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10459
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10460
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10461 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10462 * The type allows you to specify how the data for this column will be sorted.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10463 * Four types (string, numeric, date and html (which will strip HTML tags
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10464 * before sorting)) are currently available. Note that only date formats
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10465 * understood by Javascript's Date() object will be accepted as type date. For
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10466 * example: "Mar 26, 2008 5:03 PM". May take the values: 'string', 'numeric',
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10467 * 'date' or 'html' (by default). Further types can be adding through
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10468 * plug-ins.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10469 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10470 * @default null <i>Auto-detected from raw data</i>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10471 * @dtopt Columns
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10472 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10473 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10474 * // Using aoColumnDefs
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10475 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10476 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10477 * "aoColumnDefs": [
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10478 * { "sType": "html", "aTargets": [ 0 ] }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10479 * ]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10480 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10481 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10482 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10483 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10484 * // Using aoColumns
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10485 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10486 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10487 * "aoColumns": [
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10488 * { "sType": "html" },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10489 * null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10490 * null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10491 * null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10492 * null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10493 * ]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10494 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10495 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10496 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10497 "sType": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10498
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10499
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10500 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10501 * Defining the width of the column, this parameter may take any CSS value
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10502 * (3em, 20px etc). DataTables apples 'smart' widths to columns which have not
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10503 * been given a specific width through this interface ensuring that the table
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10504 * remains readable.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10505 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10506 * @default null <i>Automatic</i>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10507 * @dtopt Columns
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10508 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10509 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10510 * // Using aoColumnDefs
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10511 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10512 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10513 * "aoColumnDefs": [
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10514 * { "sWidth": "20%", "aTargets": [ 0 ] }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10515 * ]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10516 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10517 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10518 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10519 * @example
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10520 * // Using aoColumns
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10521 * $(document).ready( function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10522 * $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10523 * "aoColumns": [
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10524 * { "sWidth": "20%" },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10525 * null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10526 * null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10527 * null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10528 * null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10529 * ]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10530 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10531 * } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10532 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10533 "sWidth": null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10534 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10535
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10536
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10537
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10538 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10539 * DataTables settings object - this holds all the information needed for a
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10540 * given table, including configuration, data and current application of the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10541 * table options. DataTables does not have a single instance for each DataTable
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10542 * with the settings attached to that instance, but rather instances of the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10543 * DataTable "class" are created on-the-fly as needed (typically by a
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10544 * $().dataTable() call) and the settings object is then applied to that
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10545 * instance.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10546 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10547 * Note that this object is related to {@link DataTable.defaults} but this
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10548 * one is the internal data store for DataTables's cache of columns. It should
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10549 * NOT be manipulated outside of DataTables. Any configuration should be done
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10550 * through the initialisation options.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10551 * @namespace
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10552 * @todo Really should attach the settings object to individual instances so we
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10553 * don't need to create new instances on each $().dataTable() call (if the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10554 * table already exists). It would also save passing oSettings around and
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10555 * into every single function. However, this is a very significant
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10556 * architecture change for DataTables and will almost certainly break
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10557 * backwards compatibility with older installations. This is something that
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10558 * will be done in 2.0.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10559 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10560 DataTable.models.oSettings = {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10561 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10562 * Primary features of DataTables and their enablement state.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10563 * @namespace
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10564 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10565 "oFeatures": {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10566
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10567 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10568 * Flag to say if DataTables should automatically try to calculate the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10569 * optimum table and columns widths (true) or not (false).
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10570 * Note that this parameter will be set by the initialisation routine. To
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10571 * set a default use {@link DataTable.defaults}.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10572 * @type boolean
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10573 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10574 "bAutoWidth": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10575
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10576 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10577 * Delay the creation of TR and TD elements until they are actually
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10578 * needed by a driven page draw. This can give a significant speed
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10579 * increase for Ajax source and Javascript source data, but makes no
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10580 * difference at all fro DOM and server-side processing tables.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10581 * Note that this parameter will be set by the initialisation routine. To
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10582 * set a default use {@link DataTable.defaults}.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10583 * @type boolean
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10584 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10585 "bDeferRender": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10586
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10587 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10588 * Enable filtering on the table or not. Note that if this is disabled
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10589 * then there is no filtering at all on the table, including fnFilter.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10590 * To just remove the filtering input use sDom and remove the 'f' option.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10591 * Note that this parameter will be set by the initialisation routine. To
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10592 * set a default use {@link DataTable.defaults}.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10593 * @type boolean
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10594 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10595 "bFilter": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10596
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10597 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10598 * Table information element (the 'Showing x of y records' div) enable
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10599 * flag.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10600 * Note that this parameter will be set by the initialisation routine. To
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10601 * set a default use {@link DataTable.defaults}.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10602 * @type boolean
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10603 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10604 "bInfo": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10605
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10606 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10607 * Present a user control allowing the end user to change the page size
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10608 * when pagination is enabled.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10609 * Note that this parameter will be set by the initialisation routine. To
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10610 * set a default use {@link DataTable.defaults}.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10611 * @type boolean
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10612 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10613 "bLengthChange": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10614
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10615 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10616 * Pagination enabled or not. Note that if this is disabled then length
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10617 * changing must also be disabled.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10618 * Note that this parameter will be set by the initialisation routine. To
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10619 * set a default use {@link DataTable.defaults}.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10620 * @type boolean
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10621 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10622 "bPaginate": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10623
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10624 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10625 * Processing indicator enable flag whenever DataTables is enacting a
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10626 * user request - typically an Ajax request for server-side processing.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10627 * Note that this parameter will be set by the initialisation routine. To
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10628 * set a default use {@link DataTable.defaults}.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10629 * @type boolean
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10630 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10631 "bProcessing": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10632
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10633 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10634 * Server-side processing enabled flag - when enabled DataTables will
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10635 * get all data from the server for every draw - there is no filtering,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10636 * sorting or paging done on the client-side.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10637 * Note that this parameter will be set by the initialisation routine. To
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10638 * set a default use {@link DataTable.defaults}.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10639 * @type boolean
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10640 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10641 "bServerSide": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10642
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10643 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10644 * Sorting enablement flag.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10645 * Note that this parameter will be set by the initialisation routine. To
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10646 * set a default use {@link DataTable.defaults}.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10647 * @type boolean
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10648 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10649 "bSort": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10650
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10651 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10652 * Apply a class to the columns which are being sorted to provide a
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10653 * visual highlight or not. This can slow things down when enabled since
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10654 * there is a lot of DOM interaction.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10655 * Note that this parameter will be set by the initialisation routine. To
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10656 * set a default use {@link DataTable.defaults}.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10657 * @type boolean
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10658 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10659 "bSortClasses": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10660
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10661 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10662 * State saving enablement flag.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10663 * Note that this parameter will be set by the initialisation routine. To
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10664 * set a default use {@link DataTable.defaults}.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10665 * @type boolean
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10666 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10667 "bStateSave": null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10668 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10669
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10670
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10671 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10672 * Scrolling settings for a table.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10673 * @namespace
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10674 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10675 "oScroll": {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10676 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10677 * Indicate if DataTables should be allowed to set the padding / margin
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10678 * etc for the scrolling header elements or not. Typically you will want
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10679 * this.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10680 * Note that this parameter will be set by the initialisation routine. To
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10681 * set a default use {@link DataTable.defaults}.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10682 * @type boolean
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10683 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10684 "bAutoCss": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10685
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10686 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10687 * When the table is shorter in height than sScrollY, collapse the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10688 * table container down to the height of the table (when true).
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10689 * Note that this parameter will be set by the initialisation routine. To
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10690 * set a default use {@link DataTable.defaults}.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10691 * @type boolean
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10692 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10693 "bCollapse": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10694
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10695 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10696 * Infinite scrolling enablement flag. Now deprecated in favour of
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10697 * using the Scroller plug-in.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10698 * Note that this parameter will be set by the initialisation routine. To
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10699 * set a default use {@link DataTable.defaults}.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10700 * @type boolean
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10701 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10702 "bInfinite": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10703
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10704 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10705 * Width of the scrollbar for the web-browser's platform. Calculated
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10706 * during table initialisation.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10707 * @type int
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10708 * @default 0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10709 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10710 "iBarWidth": 0,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10711
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10712 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10713 * Space (in pixels) between the bottom of the scrolling container and
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10714 * the bottom of the scrolling viewport before the next page is loaded
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10715 * when using infinite scrolling.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10716 * Note that this parameter will be set by the initialisation routine. To
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10717 * set a default use {@link DataTable.defaults}.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10718 * @type int
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10719 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10720 "iLoadGap": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10721
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10722 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10723 * Viewport width for horizontal scrolling. Horizontal scrolling is
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10724 * disabled if an empty string.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10725 * Note that this parameter will be set by the initialisation routine. To
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10726 * set a default use {@link DataTable.defaults}.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10727 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10728 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10729 "sX": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10730
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10731 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10732 * Width to expand the table to when using x-scrolling. Typically you
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10733 * should not need to use this.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10734 * Note that this parameter will be set by the initialisation routine. To
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10735 * set a default use {@link DataTable.defaults}.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10736 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10737 * @deprecated
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10738 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10739 "sXInner": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10740
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10741 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10742 * Viewport height for vertical scrolling. Vertical scrolling is disabled
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10743 * if an empty string.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10744 * Note that this parameter will be set by the initialisation routine. To
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10745 * set a default use {@link DataTable.defaults}.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10746 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10747 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10748 "sY": null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10749 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10750
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10751 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10752 * Language information for the table.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10753 * @namespace
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10754 * @extends DataTable.defaults.oLanguage
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10755 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10756 "oLanguage": {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10757 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10758 * Information callback function. See
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10759 * {@link DataTable.defaults.fnInfoCallback}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10760 * @type function
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10761 * @default null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10762 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10763 "fnInfoCallback": null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10764 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10765
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10766 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10767 * Browser support parameters
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10768 * @namespace
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10769 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10770 "oBrowser": {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10771 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10772 * Indicate if the browser incorrectly calculates width:100% inside a
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10773 * scrolling element (IE6/7)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10774 * @type boolean
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10775 * @default false
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10776 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10777 "bScrollOversize": false
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10778 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10779
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10780 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10781 * Array referencing the nodes which are used for the features. The
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10782 * parameters of this object match what is allowed by sDom - i.e.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10783 * <ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10784 * <li>'l' - Length changing</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10785 * <li>'f' - Filtering input</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10786 * <li>'t' - The table!</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10787 * <li>'i' - Information</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10788 * <li>'p' - Pagination</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10789 * <li>'r' - pRocessing</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10790 * </ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10791 * @type array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10792 * @default []
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10793 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10794 "aanFeatures": [],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10795
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10796 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10797 * Store data information - see {@link DataTable.models.oRow} for detailed
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10798 * information.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10799 * @type array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10800 * @default []
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10801 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10802 "aoData": [],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10803
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10804 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10805 * Array of indexes which are in the current display (after filtering etc)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10806 * @type array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10807 * @default []
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10808 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10809 "aiDisplay": [],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10810
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10811 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10812 * Array of indexes for display - no filtering
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10813 * @type array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10814 * @default []
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10815 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10816 "aiDisplayMaster": [],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10817
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10818 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10819 * Store information about each column that is in use
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10820 * @type array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10821 * @default []
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10822 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10823 "aoColumns": [],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10824
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10825 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10826 * Store information about the table's header
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10827 * @type array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10828 * @default []
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10829 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10830 "aoHeader": [],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10831
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10832 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10833 * Store information about the table's footer
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10834 * @type array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10835 * @default []
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10836 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10837 "aoFooter": [],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10838
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10839 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10840 * Search data array for regular expression searching
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10841 * @type array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10842 * @default []
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10843 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10844 "asDataSearch": [],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10845
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10846 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10847 * Store the applied global search information in case we want to force a
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10848 * research or compare the old search to a new one.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10849 * Note that this parameter will be set by the initialisation routine. To
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10850 * set a default use {@link DataTable.defaults}.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10851 * @namespace
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10852 * @extends DataTable.models.oSearch
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10853 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10854 "oPreviousSearch": {},
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10855
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10856 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10857 * Store the applied search for each column - see
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10858 * {@link DataTable.models.oSearch} for the format that is used for the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10859 * filtering information for each column.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10860 * @type array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10861 * @default []
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10862 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10863 "aoPreSearchCols": [],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10864
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10865 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10866 * Sorting that is applied to the table. Note that the inner arrays are
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10867 * used in the following manner:
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10868 * <ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10869 * <li>Index 0 - column number</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10870 * <li>Index 1 - current sorting direction</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10871 * <li>Index 2 - index of asSorting for this column</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10872 * </ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10873 * Note that this parameter will be set by the initialisation routine. To
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10874 * set a default use {@link DataTable.defaults}.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10875 * @type array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10876 * @todo These inner arrays should really be objects
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10877 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10878 "aaSorting": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10879
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10880 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10881 * Sorting that is always applied to the table (i.e. prefixed in front of
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10882 * aaSorting).
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10883 * Note that this parameter will be set by the initialisation routine. To
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10884 * set a default use {@link DataTable.defaults}.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10885 * @type array|null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10886 * @default null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10887 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10888 "aaSortingFixed": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10889
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10890 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10891 * Classes to use for the striping of a table.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10892 * Note that this parameter will be set by the initialisation routine. To
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10893 * set a default use {@link DataTable.defaults}.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10894 * @type array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10895 * @default []
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10896 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10897 "asStripeClasses": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10898
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10899 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10900 * If restoring a table - we should restore its striping classes as well
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10901 * @type array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10902 * @default []
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10903 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10904 "asDestroyStripes": [],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10905
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10906 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10907 * If restoring a table - we should restore its width
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10908 * @type int
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10909 * @default 0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10910 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10911 "sDestroyWidth": 0,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10912
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10913 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10914 * Callback functions array for every time a row is inserted (i.e. on a draw).
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10915 * @type array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10916 * @default []
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10917 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10918 "aoRowCallback": [],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10919
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10920 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10921 * Callback functions for the header on each draw.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10922 * @type array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10923 * @default []
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10924 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10925 "aoHeaderCallback": [],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10926
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10927 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10928 * Callback function for the footer on each draw.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10929 * @type array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10930 * @default []
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10931 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10932 "aoFooterCallback": [],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10933
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10934 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10935 * Array of callback functions for draw callback functions
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10936 * @type array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10937 * @default []
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10938 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10939 "aoDrawCallback": [],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10940
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10941 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10942 * Array of callback functions for row created function
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10943 * @type array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10944 * @default []
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10945 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10946 "aoRowCreatedCallback": [],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10947
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10948 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10949 * Callback functions for just before the table is redrawn. A return of
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10950 * false will be used to cancel the draw.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10951 * @type array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10952 * @default []
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10953 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10954 "aoPreDrawCallback": [],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10955
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10956 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10957 * Callback functions for when the table has been initialised.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10958 * @type array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10959 * @default []
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10960 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10961 "aoInitComplete": [],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10962
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10963
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10964 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10965 * Callbacks for modifying the settings to be stored for state saving, prior to
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10966 * saving state.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10967 * @type array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10968 * @default []
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10969 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10970 "aoStateSaveParams": [],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10971
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10972 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10973 * Callbacks for modifying the settings that have been stored for state saving
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10974 * prior to using the stored values to restore the state.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10975 * @type array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10976 * @default []
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10977 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10978 "aoStateLoadParams": [],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10979
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10980 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10981 * Callbacks for operating on the settings object once the saved state has been
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10982 * loaded
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10983 * @type array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10984 * @default []
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10985 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10986 "aoStateLoaded": [],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10987
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10988 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10989 * Cache the table ID for quick access
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10990 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10991 * @default <i>Empty string</i>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10992 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10993 "sTableId": "",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10994
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10995 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10996 * The TABLE node for the main table
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10997 * @type node
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10998 * @default null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10999 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11000 "nTable": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11001
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11002 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11003 * Permanent ref to the thead element
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11004 * @type node
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11005 * @default null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11006 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11007 "nTHead": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11008
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11009 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11010 * Permanent ref to the tfoot element - if it exists
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11011 * @type node
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11012 * @default null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11013 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11014 "nTFoot": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11015
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11016 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11017 * Permanent ref to the tbody element
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11018 * @type node
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11019 * @default null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11020 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11021 "nTBody": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11022
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11023 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11024 * Cache the wrapper node (contains all DataTables controlled elements)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11025 * @type node
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11026 * @default null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11027 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11028 "nTableWrapper": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11029
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11030 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11031 * Indicate if when using server-side processing the loading of data
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11032 * should be deferred until the second draw.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11033 * Note that this parameter will be set by the initialisation routine. To
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11034 * set a default use {@link DataTable.defaults}.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11035 * @type boolean
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11036 * @default false
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11037 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11038 "bDeferLoading": false,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11039
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11040 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11041 * Indicate if all required information has been read in
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11042 * @type boolean
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11043 * @default false
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11044 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11045 "bInitialised": false,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11046
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11047 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11048 * Information about open rows. Each object in the array has the parameters
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11049 * 'nTr' and 'nParent'
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11050 * @type array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11051 * @default []
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11052 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11053 "aoOpenRows": [],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11054
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11055 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11056 * Dictate the positioning of DataTables' control elements - see
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11057 * {@link DataTable.model.oInit.sDom}.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11058 * Note that this parameter will be set by the initialisation routine. To
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11059 * set a default use {@link DataTable.defaults}.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11060 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11061 * @default null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11062 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11063 "sDom": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11064
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11065 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11066 * Which type of pagination should be used.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11067 * Note that this parameter will be set by the initialisation routine. To
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11068 * set a default use {@link DataTable.defaults}.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11069 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11070 * @default two_button
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11071 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11072 "sPaginationType": "two_button",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11073
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11074 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11075 * The cookie duration (for bStateSave) in seconds.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11076 * Note that this parameter will be set by the initialisation routine. To
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11077 * set a default use {@link DataTable.defaults}.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11078 * @type int
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11079 * @default 0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11080 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11081 "iCookieDuration": 0,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11082
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11083 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11084 * The cookie name prefix.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11085 * Note that this parameter will be set by the initialisation routine. To
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11086 * set a default use {@link DataTable.defaults}.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11087 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11088 * @default <i>Empty string</i>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11089 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11090 "sCookiePrefix": "",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11091
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11092 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11093 * Callback function for cookie creation.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11094 * Note that this parameter will be set by the initialisation routine. To
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11095 * set a default use {@link DataTable.defaults}.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11096 * @type function
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11097 * @default null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11098 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11099 "fnCookieCallback": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11100
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11101 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11102 * Array of callback functions for state saving. Each array element is an
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11103 * object with the following parameters:
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11104 * <ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11105 * <li>function:fn - function to call. Takes two parameters, oSettings
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11106 * and the JSON string to save that has been thus far created. Returns
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11107 * a JSON string to be inserted into a json object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11108 * (i.e. '"param": [ 0, 1, 2]')</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11109 * <li>string:sName - name of callback</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11110 * </ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11111 * @type array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11112 * @default []
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11113 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11114 "aoStateSave": [],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11115
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11116 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11117 * Array of callback functions for state loading. Each array element is an
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11118 * object with the following parameters:
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11119 * <ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11120 * <li>function:fn - function to call. Takes two parameters, oSettings
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11121 * and the object stored. May return false to cancel state loading</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11122 * <li>string:sName - name of callback</li>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11123 * </ul>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11124 * @type array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11125 * @default []
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11126 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11127 "aoStateLoad": [],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11128
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11129 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11130 * State that was loaded from the cookie. Useful for back reference
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11131 * @type object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11132 * @default null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11133 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11134 "oLoadedState": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11135
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11136 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11137 * Source url for AJAX data for the table.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11138 * Note that this parameter will be set by the initialisation routine. To
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11139 * set a default use {@link DataTable.defaults}.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11140 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11141 * @default null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11142 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11143 "sAjaxSource": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11144
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11145 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11146 * Property from a given object from which to read the table data from. This
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11147 * can be an empty string (when not server-side processing), in which case
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11148 * it is assumed an an array is given directly.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11149 * Note that this parameter will be set by the initialisation routine. To
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11150 * set a default use {@link DataTable.defaults}.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11151 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11152 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11153 "sAjaxDataProp": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11154
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11155 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11156 * Note if draw should be blocked while getting data
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11157 * @type boolean
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11158 * @default true
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11159 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11160 "bAjaxDataGet": true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11161
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11162 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11163 * The last jQuery XHR object that was used for server-side data gathering.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11164 * This can be used for working with the XHR information in one of the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11165 * callbacks
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11166 * @type object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11167 * @default null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11168 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11169 "jqXHR": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11170
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11171 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11172 * Function to get the server-side data.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11173 * Note that this parameter will be set by the initialisation routine. To
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11174 * set a default use {@link DataTable.defaults}.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11175 * @type function
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11176 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11177 "fnServerData": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11178
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11179 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11180 * Functions which are called prior to sending an Ajax request so extra
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11181 * parameters can easily be sent to the server
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11182 * @type array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11183 * @default []
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11184 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11185 "aoServerParams": [],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11186
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11187 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11188 * Send the XHR HTTP method - GET or POST (could be PUT or DELETE if
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11189 * required).
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11190 * Note that this parameter will be set by the initialisation routine. To
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11191 * set a default use {@link DataTable.defaults}.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11192 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11193 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11194 "sServerMethod": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11195
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11196 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11197 * Format numbers for display.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11198 * Note that this parameter will be set by the initialisation routine. To
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11199 * set a default use {@link DataTable.defaults}.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11200 * @type function
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11201 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11202 "fnFormatNumber": true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11203
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11204 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11205 * List of options that can be used for the user selectable length menu.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11206 * Note that this parameter will be set by the initialisation routine. To
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11207 * set a default use {@link DataTable.defaults}.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11208 * @type array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11209 * @default []
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11210 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11211 "aLengthMenu": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11212
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11213 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11214 * Counter for the draws that the table does. Also used as a tracker for
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11215 * server-side processing
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11216 * @type int
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11217 * @default 0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11218 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11219 "iDraw": 0,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11220
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11221 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11222 * Indicate if a redraw is being done - useful for Ajax
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11223 * @type boolean
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11224 * @default false
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11225 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11226 "bDrawing": false,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11227
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11228 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11229 * Draw index (iDraw) of the last error when parsing the returned data
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11230 * @type int
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11231 * @default -1
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11232 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11233 "iDrawError": -1,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11234
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11235 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11236 * Paging display length
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11237 * @type int
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11238 * @default 10
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11239 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11240 "_iDisplayLength": 10,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11241
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11242 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11243 * Paging start point - aiDisplay index
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11244 * @type int
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11245 * @default 0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11246 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11247 "_iDisplayStart": 0,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11248
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11249 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11250 * Paging end point - aiDisplay index. Use fnDisplayEnd rather than
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11251 * this property to get the end point
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11252 * @type int
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11253 * @default 10
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11254 * @private
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11255 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11256 "_iDisplayEnd": 10,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11257
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11258 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11259 * Server-side processing - number of records in the result set
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11260 * (i.e. before filtering), Use fnRecordsTotal rather than
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11261 * this property to get the value of the number of records, regardless of
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11262 * the server-side processing setting.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11263 * @type int
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11264 * @default 0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11265 * @private
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11266 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11267 "_iRecordsTotal": 0,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11268
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11269 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11270 * Server-side processing - number of records in the current display set
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11271 * (i.e. after filtering). Use fnRecordsDisplay rather than
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11272 * this property to get the value of the number of records, regardless of
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11273 * the server-side processing setting.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11274 * @type boolean
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11275 * @default 0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11276 * @private
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11277 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11278 "_iRecordsDisplay": 0,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11279
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11280 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11281 * Flag to indicate if jQuery UI marking and classes should be used.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11282 * Note that this parameter will be set by the initialisation routine. To
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11283 * set a default use {@link DataTable.defaults}.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11284 * @type boolean
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11285 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11286 "bJUI": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11287
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11288 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11289 * The classes to use for the table
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11290 * @type object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11291 * @default {}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11292 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11293 "oClasses": {},
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11294
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11295 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11296 * Flag attached to the settings object so you can check in the draw
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11297 * callback if filtering has been done in the draw. Deprecated in favour of
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11298 * events.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11299 * @type boolean
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11300 * @default false
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11301 * @deprecated
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11302 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11303 "bFiltered": false,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11304
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11305 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11306 * Flag attached to the settings object so you can check in the draw
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11307 * callback if sorting has been done in the draw. Deprecated in favour of
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11308 * events.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11309 * @type boolean
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11310 * @default false
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11311 * @deprecated
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11312 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11313 "bSorted": false,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11314
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11315 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11316 * Indicate that if multiple rows are in the header and there is more than
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11317 * one unique cell per column, if the top one (true) or bottom one (false)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11318 * should be used for sorting / title by DataTables.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11319 * Note that this parameter will be set by the initialisation routine. To
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11320 * set a default use {@link DataTable.defaults}.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11321 * @type boolean
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11322 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11323 "bSortCellsTop": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11324
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11325 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11326 * Initialisation object that is used for the table
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11327 * @type object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11328 * @default null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11329 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11330 "oInit": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11331
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11332 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11333 * Destroy callback functions - for plug-ins to attach themselves to the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11334 * destroy so they can clean up markup and events.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11335 * @type array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11336 * @default []
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11337 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11338 "aoDestroyCallback": [],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11339
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11340
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11341 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11342 * Get the number of records in the current record set, before filtering
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11343 * @type function
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11344 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11345 "fnRecordsTotal": function ()
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11346 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11347 if ( this.oFeatures.bServerSide ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11348 return parseInt(this._iRecordsTotal, 10);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11349 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11350 return this.aiDisplayMaster.length;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11351 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11352 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11353
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11354 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11355 * Get the number of records in the current record set, after filtering
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11356 * @type function
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11357 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11358 "fnRecordsDisplay": function ()
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11359 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11360 if ( this.oFeatures.bServerSide ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11361 return parseInt(this._iRecordsDisplay, 10);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11362 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11363 return this.aiDisplay.length;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11364 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11365 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11366
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11367 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11368 * Set the display end point - aiDisplay index
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11369 * @type function
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11370 * @todo Should do away with _iDisplayEnd and calculate it on-the-fly here
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11371 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11372 "fnDisplayEnd": function ()
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11373 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11374 if ( this.oFeatures.bServerSide ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11375 if ( this.oFeatures.bPaginate === false || this._iDisplayLength == -1 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11376 return this._iDisplayStart+this.aiDisplay.length;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11377 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11378 return Math.min( this._iDisplayStart+this._iDisplayLength,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11379 this._iRecordsDisplay );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11380 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11381 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11382 return this._iDisplayEnd;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11383 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11384 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11385
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11386 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11387 * The DataTables object for this table
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11388 * @type object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11389 * @default null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11390 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11391 "oInstance": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11392
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11393 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11394 * Unique identifier for each instance of the DataTables object. If there
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11395 * is an ID on the table node, then it takes that value, otherwise an
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11396 * incrementing internal counter is used.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11397 * @type string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11398 * @default null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11399 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11400 "sInstance": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11401
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11402 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11403 * tabindex attribute value that is added to DataTables control elements, allowing
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11404 * keyboard navigation of the table and its controls.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11405 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11406 "iTabIndex": 0,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11407
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11408 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11409 * DIV container for the footer scrolling table if scrolling
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11410 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11411 "nScrollHead": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11412
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11413 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11414 * DIV container for the footer scrolling table if scrolling
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11415 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11416 "nScrollFoot": null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11417 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11418
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11419 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11420 * Extension object for DataTables that is used to provide all extension options.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11421 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11422 * Note that the <i>DataTable.ext</i> object is available through
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11423 * <i>jQuery.fn.dataTable.ext</i> where it may be accessed and manipulated. It is
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11424 * also aliased to <i>jQuery.fn.dataTableExt</i> for historic reasons.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11425 * @namespace
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11426 * @extends DataTable.models.ext
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11427 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11428 DataTable.ext = $.extend( true, {}, DataTable.models.ext );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11429
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11430 $.extend( DataTable.ext.oStdClasses, {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11431 "sTable": "dataTable",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11432
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11433 /* Two buttons buttons */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11434 "sPagePrevEnabled": "paginate_enabled_previous",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11435 "sPagePrevDisabled": "paginate_disabled_previous",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11436 "sPageNextEnabled": "paginate_enabled_next",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11437 "sPageNextDisabled": "paginate_disabled_next",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11438 "sPageJUINext": "",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11439 "sPageJUIPrev": "",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11440
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11441 /* Full numbers paging buttons */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11442 "sPageButton": "paginate_button",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11443 "sPageButtonActive": "paginate_active",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11444 "sPageButtonStaticDisabled": "paginate_button paginate_button_disabled",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11445 "sPageFirst": "first",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11446 "sPagePrevious": "previous",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11447 "sPageNext": "next",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11448 "sPageLast": "last",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11449
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11450 /* Striping classes */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11451 "sStripeOdd": "odd",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11452 "sStripeEven": "even",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11453
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11454 /* Empty row */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11455 "sRowEmpty": "dataTables_empty",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11456
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11457 /* Features */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11458 "sWrapper": "dataTables_wrapper",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11459 "sFilter": "dataTables_filter",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11460 "sInfo": "dataTables_info",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11461 "sPaging": "dataTables_paginate paging_", /* Note that the type is postfixed */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11462 "sLength": "dataTables_length",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11463 "sProcessing": "dataTables_processing",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11464
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11465 /* Sorting */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11466 "sSortAsc": "sorting_asc",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11467 "sSortDesc": "sorting_desc",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11468 "sSortable": "sorting", /* Sortable in both directions */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11469 "sSortableAsc": "sorting_asc_disabled",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11470 "sSortableDesc": "sorting_desc_disabled",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11471 "sSortableNone": "sorting_disabled",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11472 "sSortColumn": "sorting_", /* Note that an int is postfixed for the sorting order */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11473 "sSortJUIAsc": "",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11474 "sSortJUIDesc": "",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11475 "sSortJUI": "",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11476 "sSortJUIAscAllowed": "",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11477 "sSortJUIDescAllowed": "",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11478 "sSortJUIWrapper": "",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11479 "sSortIcon": "",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11480
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11481 /* Scrolling */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11482 "sScrollWrapper": "dataTables_scroll",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11483 "sScrollHead": "dataTables_scrollHead",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11484 "sScrollHeadInner": "dataTables_scrollHeadInner",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11485 "sScrollBody": "dataTables_scrollBody",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11486 "sScrollFoot": "dataTables_scrollFoot",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11487 "sScrollFootInner": "dataTables_scrollFootInner",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11488
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11489 /* Misc */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11490 "sFooterTH": "",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11491 "sJUIHeader": "",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11492 "sJUIFooter": ""
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11493 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11494
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11495
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11496 $.extend( DataTable.ext.oJUIClasses, DataTable.ext.oStdClasses, {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11497 /* Two buttons buttons */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11498 "sPagePrevEnabled": "fg-button ui-button ui-state-default ui-corner-left",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11499 "sPagePrevDisabled": "fg-button ui-button ui-state-default ui-corner-left ui-state-disabled",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11500 "sPageNextEnabled": "fg-button ui-button ui-state-default ui-corner-right",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11501 "sPageNextDisabled": "fg-button ui-button ui-state-default ui-corner-right ui-state-disabled",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11502 "sPageJUINext": "ui-icon ui-icon-circle-arrow-e",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11503 "sPageJUIPrev": "ui-icon ui-icon-circle-arrow-w",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11504
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11505 /* Full numbers paging buttons */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11506 "sPageButton": "fg-button ui-button ui-state-default",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11507 "sPageButtonActive": "fg-button ui-button ui-state-default ui-state-disabled",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11508 "sPageButtonStaticDisabled": "fg-button ui-button ui-state-default ui-state-disabled",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11509 "sPageFirst": "first ui-corner-tl ui-corner-bl",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11510 "sPageLast": "last ui-corner-tr ui-corner-br",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11511
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11512 /* Features */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11513 "sPaging": "dataTables_paginate fg-buttonset ui-buttonset fg-buttonset-multi "+
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11514 "ui-buttonset-multi paging_", /* Note that the type is postfixed */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11515
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11516 /* Sorting */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11517 "sSortAsc": "ui-state-default",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11518 "sSortDesc": "ui-state-default",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11519 "sSortable": "ui-state-default",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11520 "sSortableAsc": "ui-state-default",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11521 "sSortableDesc": "ui-state-default",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11522 "sSortableNone": "ui-state-default",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11523 "sSortJUIAsc": "css_right ui-icon ui-icon-triangle-1-n",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11524 "sSortJUIDesc": "css_right ui-icon ui-icon-triangle-1-s",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11525 "sSortJUI": "css_right ui-icon ui-icon-carat-2-n-s",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11526 "sSortJUIAscAllowed": "css_right ui-icon ui-icon-carat-1-n",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11527 "sSortJUIDescAllowed": "css_right ui-icon ui-icon-carat-1-s",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11528 "sSortJUIWrapper": "DataTables_sort_wrapper",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11529 "sSortIcon": "DataTables_sort_icon",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11530
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11531 /* Scrolling */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11532 "sScrollHead": "dataTables_scrollHead ui-state-default",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11533 "sScrollFoot": "dataTables_scrollFoot ui-state-default",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11534
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11535 /* Misc */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11536 "sFooterTH": "ui-state-default",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11537 "sJUIHeader": "fg-toolbar ui-toolbar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11538 "sJUIFooter": "fg-toolbar ui-toolbar ui-widget-header ui-corner-bl ui-corner-br ui-helper-clearfix"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11539 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11540
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11541 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11542 * Variable: oPagination
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11543 * Purpose:
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11544 * Scope: jQuery.fn.dataTableExt
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11545 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11546 $.extend( DataTable.ext.oPagination, {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11547 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11548 * Variable: two_button
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11549 * Purpose: Standard two button (forward/back) pagination
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11550 * Scope: jQuery.fn.dataTableExt.oPagination
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11551 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11552 "two_button": {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11553 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11554 * Function: oPagination.two_button.fnInit
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11555 * Purpose: Initialise dom elements required for pagination with forward/back buttons only
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11556 * Returns: -
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11557 * Inputs: object:oSettings - dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11558 * node:nPaging - the DIV which contains this pagination control
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11559 * function:fnCallbackDraw - draw function which must be called on update
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11560 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11561 "fnInit": function ( oSettings, nPaging, fnCallbackDraw )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11562 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11563 var oLang = oSettings.oLanguage.oPaginate;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11564 var oClasses = oSettings.oClasses;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11565 var fnClickHandler = function ( e ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11566 if ( oSettings.oApi._fnPageChange( oSettings, e.data.action ) )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11567 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11568 fnCallbackDraw( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11569 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11570 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11571
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11572 var sAppend = (!oSettings.bJUI) ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11573 '<a class="'+oSettings.oClasses.sPagePrevDisabled+'" tabindex="'+oSettings.iTabIndex+'" role="button">'+oLang.sPrevious+'</a>'+
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11574 '<a class="'+oSettings.oClasses.sPageNextDisabled+'" tabindex="'+oSettings.iTabIndex+'" role="button">'+oLang.sNext+'</a>'
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11575 :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11576 '<a class="'+oSettings.oClasses.sPagePrevDisabled+'" tabindex="'+oSettings.iTabIndex+'" role="button"><span class="'+oSettings.oClasses.sPageJUIPrev+'"></span></a>'+
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11577 '<a class="'+oSettings.oClasses.sPageNextDisabled+'" tabindex="'+oSettings.iTabIndex+'" role="button"><span class="'+oSettings.oClasses.sPageJUINext+'"></span></a>';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11578 $(nPaging).append( sAppend );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11579
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11580 var els = $('a', nPaging);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11581 var nPrevious = els[0],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11582 nNext = els[1];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11583
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11584 oSettings.oApi._fnBindAction( nPrevious, {action: "previous"}, fnClickHandler );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11585 oSettings.oApi._fnBindAction( nNext, {action: "next"}, fnClickHandler );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11586
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11587 /* ID the first elements only */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11588 if ( !oSettings.aanFeatures.p )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11589 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11590 nPaging.id = oSettings.sTableId+'_paginate';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11591 nPrevious.id = oSettings.sTableId+'_previous';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11592 nNext.id = oSettings.sTableId+'_next';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11593
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11594 nPrevious.setAttribute('aria-controls', oSettings.sTableId);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11595 nNext.setAttribute('aria-controls', oSettings.sTableId);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11596 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11597 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11598
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11599 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11600 * Function: oPagination.two_button.fnUpdate
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11601 * Purpose: Update the two button pagination at the end of the draw
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11602 * Returns: -
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11603 * Inputs: object:oSettings - dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11604 * function:fnCallbackDraw - draw function to call on page change
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11605 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11606 "fnUpdate": function ( oSettings, fnCallbackDraw )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11607 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11608 if ( !oSettings.aanFeatures.p )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11609 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11610 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11611 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11612
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11613 var oClasses = oSettings.oClasses;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11614 var an = oSettings.aanFeatures.p;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11615 var nNode;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11616
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11617 /* Loop over each instance of the pager */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11618 for ( var i=0, iLen=an.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11619 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11620 nNode = an[i].firstChild;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11621 if ( nNode )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11622 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11623 /* Previous page */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11624 nNode.className = ( oSettings._iDisplayStart === 0 ) ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11625 oClasses.sPagePrevDisabled : oClasses.sPagePrevEnabled;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11626
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11627 /* Next page */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11628 nNode = nNode.nextSibling;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11629 nNode.className = ( oSettings.fnDisplayEnd() == oSettings.fnRecordsDisplay() ) ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11630 oClasses.sPageNextDisabled : oClasses.sPageNextEnabled;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11631 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11632 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11633 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11634 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11635
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11636
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11637 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11638 * Variable: iFullNumbersShowPages
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11639 * Purpose: Change the number of pages which can be seen
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11640 * Scope: jQuery.fn.dataTableExt.oPagination
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11641 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11642 "iFullNumbersShowPages": 5,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11643
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11644 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11645 * Variable: full_numbers
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11646 * Purpose: Full numbers pagination
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11647 * Scope: jQuery.fn.dataTableExt.oPagination
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11648 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11649 "full_numbers": {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11650 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11651 * Function: oPagination.full_numbers.fnInit
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11652 * Purpose: Initialise dom elements required for pagination with a list of the pages
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11653 * Returns: -
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11654 * Inputs: object:oSettings - dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11655 * node:nPaging - the DIV which contains this pagination control
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11656 * function:fnCallbackDraw - draw function which must be called on update
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11657 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11658 "fnInit": function ( oSettings, nPaging, fnCallbackDraw )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11659 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11660 var oLang = oSettings.oLanguage.oPaginate;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11661 var oClasses = oSettings.oClasses;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11662 var fnClickHandler = function ( e ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11663 if ( oSettings.oApi._fnPageChange( oSettings, e.data.action ) )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11664 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11665 fnCallbackDraw( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11666 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11667 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11668
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11669 $(nPaging).append(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11670 '<a tabindex="'+oSettings.iTabIndex+'" class="'+oClasses.sPageButton+" "+oClasses.sPageFirst+'">'+oLang.sFirst+'</a>'+
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11671 '<a tabindex="'+oSettings.iTabIndex+'" class="'+oClasses.sPageButton+" "+oClasses.sPagePrevious+'">'+oLang.sPrevious+'</a>'+
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11672 '<span></span>'+
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11673 '<a tabindex="'+oSettings.iTabIndex+'" class="'+oClasses.sPageButton+" "+oClasses.sPageNext+'">'+oLang.sNext+'</a>'+
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11674 '<a tabindex="'+oSettings.iTabIndex+'" class="'+oClasses.sPageButton+" "+oClasses.sPageLast+'">'+oLang.sLast+'</a>'
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11675 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11676 var els = $('a', nPaging);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11677 var nFirst = els[0],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11678 nPrev = els[1],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11679 nNext = els[2],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11680 nLast = els[3];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11681
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11682 oSettings.oApi._fnBindAction( nFirst, {action: "first"}, fnClickHandler );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11683 oSettings.oApi._fnBindAction( nPrev, {action: "previous"}, fnClickHandler );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11684 oSettings.oApi._fnBindAction( nNext, {action: "next"}, fnClickHandler );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11685 oSettings.oApi._fnBindAction( nLast, {action: "last"}, fnClickHandler );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11686
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11687 /* ID the first elements only */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11688 if ( !oSettings.aanFeatures.p )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11689 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11690 nPaging.id = oSettings.sTableId+'_paginate';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11691 nFirst.id =oSettings.sTableId+'_first';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11692 nPrev.id =oSettings.sTableId+'_previous';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11693 nNext.id =oSettings.sTableId+'_next';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11694 nLast.id =oSettings.sTableId+'_last';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11695 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11696 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11697
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11698 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11699 * Function: oPagination.full_numbers.fnUpdate
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11700 * Purpose: Update the list of page buttons shows
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11701 * Returns: -
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11702 * Inputs: object:oSettings - dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11703 * function:fnCallbackDraw - draw function to call on page change
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11704 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11705 "fnUpdate": function ( oSettings, fnCallbackDraw )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11706 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11707 if ( !oSettings.aanFeatures.p )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11708 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11709 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11710 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11711
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11712 var iPageCount = DataTable.ext.oPagination.iFullNumbersShowPages;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11713 var iPageCountHalf = Math.floor(iPageCount / 2);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11714 var iPages = Math.ceil((oSettings.fnRecordsDisplay()) / oSettings._iDisplayLength);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11715 var iCurrentPage = Math.ceil(oSettings._iDisplayStart / oSettings._iDisplayLength) + 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11716 var sList = "";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11717 var iStartButton, iEndButton, i, iLen;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11718 var oClasses = oSettings.oClasses;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11719 var anButtons, anStatic, nPaginateList, nNode;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11720 var an = oSettings.aanFeatures.p;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11721 var fnBind = function (j) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11722 oSettings.oApi._fnBindAction( this, {"page": j+iStartButton-1}, function(e) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11723 /* Use the information in the element to jump to the required page */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11724 oSettings.oApi._fnPageChange( oSettings, e.data.page );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11725 fnCallbackDraw( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11726 e.preventDefault();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11727 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11728 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11729
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11730 /* Pages calculation */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11731 if ( oSettings._iDisplayLength === -1 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11732 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11733 iStartButton = 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11734 iEndButton = 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11735 iCurrentPage = 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11736 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11737 else if (iPages < iPageCount)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11738 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11739 iStartButton = 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11740 iEndButton = iPages;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11741 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11742 else if (iCurrentPage <= iPageCountHalf)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11743 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11744 iStartButton = 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11745 iEndButton = iPageCount;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11746 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11747 else if (iCurrentPage >= (iPages - iPageCountHalf))
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11748 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11749 iStartButton = iPages - iPageCount + 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11750 iEndButton = iPages;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11751 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11752 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11753 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11754 iStartButton = iCurrentPage - Math.ceil(iPageCount / 2) + 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11755 iEndButton = iStartButton + iPageCount - 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11756 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11757
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11758
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11759 /* Build the dynamic list */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11760 for ( i=iStartButton ; i<=iEndButton ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11761 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11762 sList += (iCurrentPage !== i) ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11763 '<a tabindex="'+oSettings.iTabIndex+'" class="'+oClasses.sPageButton+'">'+oSettings.fnFormatNumber(i)+'</a>' :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11764 '<a tabindex="'+oSettings.iTabIndex+'" class="'+oClasses.sPageButtonActive+'">'+oSettings.fnFormatNumber(i)+'</a>';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11765 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11766
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11767 /* Loop over each instance of the pager */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11768 for ( i=0, iLen=an.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11769 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11770 nNode = an[i];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11771 if ( !nNode.hasChildNodes() )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11772 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11773 continue;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11774 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11775
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11776 /* Build up the dynamic list first - html and listeners */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11777 $('span:eq(0)', nNode)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11778 .html( sList )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11779 .children('a').each( fnBind );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11780
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11781 /* Update the permanent button's classes */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11782 anButtons = nNode.getElementsByTagName('a');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11783 anStatic = [
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11784 anButtons[0], anButtons[1],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11785 anButtons[anButtons.length-2], anButtons[anButtons.length-1]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11786 ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11787
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11788 $(anStatic).removeClass( oClasses.sPageButton+" "+oClasses.sPageButtonActive+" "+oClasses.sPageButtonStaticDisabled );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11789 $([anStatic[0], anStatic[1]]).addClass(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11790 (iCurrentPage==1) ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11791 oClasses.sPageButtonStaticDisabled :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11792 oClasses.sPageButton
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11793 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11794 $([anStatic[2], anStatic[3]]).addClass(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11795 (iPages===0 || iCurrentPage===iPages || oSettings._iDisplayLength===-1) ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11796 oClasses.sPageButtonStaticDisabled :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11797 oClasses.sPageButton
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11798 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11799 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11800 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11801 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11802 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11803
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11804 $.extend( DataTable.ext.oSort, {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11805 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11806 * text sorting
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11807 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11808 "string-pre": function ( a )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11809 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11810 if ( typeof a != 'string' ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11811 a = (a !== null && a.toString) ? a.toString() : '';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11812 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11813 return a.toLowerCase();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11814 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11815
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11816 "string-asc": function ( a, b )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11817 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11818 // setup temp-scope variables for comparison evauluation
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11819 var x = a.toString().toLowerCase() || '', y = b.toString().toLowerCase() || '',
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11820 nC = String.fromCharCode(0),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11821 xN = x.replace(/([-]{0,1}[0-9.]{1,})/g, nC + '$1' + nC).split(nC),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11822 yN = y.replace(/([-]{0,1}[0-9.]{1,})/g, nC + '$1' + nC).split(nC),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11823 xD = (new Date(x)).getTime(), yD = (new Date(y)).getTime();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11824 // natural sorting of dates
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11825 if ( xD && yD && xD < yD )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11826 return -1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11827 else if ( xD && yD && xD > yD )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11828 return 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11829 // natural sorting through split numeric strings and default strings
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11830 for ( var cLoc=0, numS = Math.max( xN.length, yN.length ); cLoc < numS; cLoc++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11831 if ( ( parseFloat( xN[cLoc] ) || xN[cLoc] ) < ( parseFloat( yN[cLoc] ) || yN[cLoc] ) )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11832 return -1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11833 else if ( ( parseFloat( xN[cLoc] ) || xN[cLoc] ) > ( parseFloat( yN[cLoc] ) || yN[cLoc] ) )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11834 return 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11835 return 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11836
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11837 return ((x < y) ? -1 : ((x > y) ? 1 : 0));
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11838 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11839
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11840 "string-desc": function ( a, b )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11841 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11842 // setup temp-scope variables for comparison evauluation
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11843 var x = a.toString().toLowerCase() || '', y = b.toString().toLowerCase() || '',
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11844 nC = String.fromCharCode(0),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11845 xN = x.replace(/([-]{0,1}[0-9.]{1,})/g, nC + '$1' + nC).split(nC),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11846 yN = y.replace(/([-]{0,1}[0-9.]{1,})/g, nC + '$1' + nC).split(nC),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11847 xD = (new Date(x)).getTime(), yD = (new Date(y)).getTime();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11848 // natural sorting of dates
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11849 if ( xD && yD && xD < yD )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11850 return 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11851 else if ( xD && yD && xD > yD )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11852 return -1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11853 // natural sorting through split numeric strings and default strings
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11854 for ( var cLoc=0, numS = Math.max( xN.length, yN.length ); cLoc < numS; cLoc++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11855 if ( ( parseFloat( xN[cLoc] ) || xN[cLoc] ) < ( parseFloat( yN[cLoc] ) || yN[cLoc] ) )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11856 return 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11857 else if ( ( parseFloat( xN[cLoc] ) || xN[cLoc] ) > ( parseFloat( yN[cLoc] ) || yN[cLoc] ) )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11858 return -1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11859 return 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11860 return ((x < y) ? 1 : ((x > y) ? -1 : 0));
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11861 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11862
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11863
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11864 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11865 * html sorting (ignore html tags)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11866 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11867 "html-pre": function ( a )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11868 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11869 return a.replace( /<.*?>/g, "" ).toLowerCase();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11870 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11871
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11872 "html-asc": function ( x, y )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11873 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11874 return ((x < y) ? -1 : ((x > y) ? 1 : 0));
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11875 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11876
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11877 "html-desc": function ( x, y )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11878 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11879 return ((x < y) ? 1 : ((x > y) ? -1 : 0));
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11880 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11881
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11882
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11883 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11884 * date sorting
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11885 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11886 "date-pre": function ( a )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11887 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11888 var x = Date.parse( a );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11889
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11890 if ( isNaN(x) || x==="" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11891 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11892 x = Date.parse( "01/01/1970 00:00:00" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11893 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11894 return x;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11895 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11896
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11897 "date-asc": function ( x, y )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11898 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11899 return x - y;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11900 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11901
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11902 "date-desc": function ( x, y )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11903 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11904 return y - x;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11905 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11906
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11907
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11908 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11909 * numerical sorting
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11910 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11911 "numeric-pre": function ( a )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11912 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11913 return (a=="-" || a==="") ? 0 : a*1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11914 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11915
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11916 "numeric-asc": function ( x, y )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11917 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11918 return x - y;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11919 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11920
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11921 "numeric-desc": function ( x, y )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11922 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11923 return y - x;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11924 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11925 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11926
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11927
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11928 $.extend( DataTable.ext.aTypes, [
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11929 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11930 * Function: -
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11931 * Purpose: Check to see if a string is numeric
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11932 * Returns: string:'numeric' or null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11933 * Inputs: mixed:sText - string to check
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11934 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11935 function ( sData )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11936 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11937 /* Allow zero length strings as a number */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11938 if ( typeof sData === 'number' )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11939 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11940 return 'numeric';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11941 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11942 else if ( typeof sData !== 'string' )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11943 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11944 return null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11945 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11946
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11947 var sValidFirstChars = "0123456789-";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11948 var sValidChars = "0123456789.";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11949 var Char;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11950 var bDecimal = false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11951
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11952 /* Check for a valid first char (no period and allow negatives) */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11953 Char = sData.charAt(0);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11954 if (sValidFirstChars.indexOf(Char) == -1)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11955 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11956 return null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11957 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11958
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11959 /* Check all the other characters are valid */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11960 for ( var i=1 ; i<sData.length ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11961 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11962 Char = sData.charAt(i);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11963 if (sValidChars.indexOf(Char) == -1)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11964 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11965 return null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11966 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11967
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11968 /* Only allowed one decimal place... */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11969 if ( Char == "." )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11970 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11971 if ( bDecimal )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11972 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11973 return null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11974 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11975 bDecimal = true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11976 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11977 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11978
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11979 return 'numeric';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11980 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11981
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11982 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11983 * Function: -
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11984 * Purpose: Check to see if a string is actually a formatted date
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11985 * Returns: string:'date' or null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11986 * Inputs: string:sText - string to check
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11987 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11988 function ( sData )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11989 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11990 var iParse = Date.parse(sData);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11991 if ( (iParse !== null && !isNaN(iParse)) || (typeof sData === 'string' && sData.length === 0) )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11992 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11993 return 'date';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11994 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11995 return null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11996 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11997
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11998 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11999 * Function: -
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12000 * Purpose: Check to see if a string should be treated as an HTML string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12001 * Returns: string:'html' or null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12002 * Inputs: string:sText - string to check
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12003 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12004 function ( sData )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12005 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12006 if ( typeof sData === 'string' && sData.indexOf('<') != -1 && sData.indexOf('>') != -1 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12007 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12008 return 'html';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12009 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12010 return null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12011 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12012 ] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12013
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12014
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12015 // jQuery aliases
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12016 $.fn.DataTable = DataTable;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12017 $.fn.dataTable = DataTable;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12018 $.fn.dataTableSettings = DataTable.settings;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12019 $.fn.dataTableExt = DataTable.ext;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12020
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12021
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12022 // Information about events fired by DataTables - for documentation.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12023 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12024 * Draw event, fired whenever the table is redrawn on the page, at the same point as
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12025 * fnDrawCallback. This may be useful for binding events or performing calculations when
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12026 * the table is altered at all.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12027 * @name DataTable#draw
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12028 * @event
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12029 * @param {event} e jQuery event object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12030 * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12031 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12032
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12033 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12034 * Filter event, fired when the filtering applied to the table (using the build in global
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12035 * global filter, or column filters) is altered.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12036 * @name DataTable#filter
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12037 * @event
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12038 * @param {event} e jQuery event object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12039 * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12040 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12041
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12042 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12043 * Page change event, fired when the paging of the table is altered.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12044 * @name DataTable#page
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12045 * @event
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12046 * @param {event} e jQuery event object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12047 * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12048 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12049
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12050 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12051 * Sort event, fired when the sorting applied to the table is altered.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12052 * @name DataTable#sort
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12053 * @event
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12054 * @param {event} e jQuery event object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12055 * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12056 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12057
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12058 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12059 * DataTables initialisation complete event, fired when the table is fully drawn,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12060 * including Ajax data loaded, if Ajax data is required.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12061 * @name DataTable#init
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12062 * @event
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12063 * @param {event} e jQuery event object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12064 * @param {object} oSettings DataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12065 * @param {object} json The JSON object request from the server - only
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12066 * present if client-side Ajax sourced data is used</li></ol>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12067 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12068
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12069 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12070 * State save event, fired when the table has changed state a new state save is required.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12071 * This method allows modification of the state saving object prior to actually doing the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12072 * save, including addition or other state properties (for plug-ins) or modification
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12073 * of a DataTables core property.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12074 * @name DataTable#stateSaveParams
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12075 * @event
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12076 * @param {event} e jQuery event object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12077 * @param {object} oSettings DataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12078 * @param {object} json The state information to be saved
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12079 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12080
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12081 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12082 * State load event, fired when the table is loading state from the stored data, but
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12083 * prior to the settings object being modified by the saved state - allowing modification
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12084 * of the saved state is required or loading of state for a plug-in.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12085 * @name DataTable#stateLoadParams
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12086 * @event
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12087 * @param {event} e jQuery event object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12088 * @param {object} oSettings DataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12089 * @param {object} json The saved state information
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12090 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12091
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12092 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12093 * State loaded event, fired when state has been loaded from stored data and the settings
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12094 * object has been modified by the loaded data.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12095 * @name DataTable#stateLoaded
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12096 * @event
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12097 * @param {event} e jQuery event object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12098 * @param {object} oSettings DataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12099 * @param {object} json The saved state information
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12100 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12101
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12102 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12103 * Processing event, fired when DataTables is doing some kind of processing (be it,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12104 * sort, filter or anything else). Can be used to indicate to the end user that
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12105 * there is something happening, or that something has finished.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12106 * @name DataTable#processing
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12107 * @event
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12108 * @param {event} e jQuery event object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12109 * @param {object} oSettings DataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12110 * @param {boolean} bShow Flag for if DataTables is doing processing or not
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12111 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12112
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12113 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12114 * Ajax (XHR) event, fired whenever an Ajax request is completed from a request to
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12115 * made to the server for new data (note that this trigger is called in fnServerData,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12116 * if you override fnServerData and which to use this event, you need to trigger it in
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12117 * you success function).
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12118 * @name DataTable#xhr
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12119 * @event
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12120 * @param {event} e jQuery event object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12121 * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12122 * @param {object} json JSON returned from the server
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12123 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12124
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12125 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12126 * Destroy event, fired when the DataTable is destroyed by calling fnDestroy or passing
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12127 * the bDestroy:true parameter in the initialisation object. This can be used to remove
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12128 * bound events, added DOM nodes, etc.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12129 * @name DataTable#destroy
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12130 * @event
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12131 * @param {event} e jQuery event object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12132 * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12133 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12134 }));
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12135
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12136 }(window, document));
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12137