4 * Draw the table for the first time, adding all required features
5 * @param {object} oSettings dataTables settings object
6 * @memberof DataTable#oApi
8 function _fnInitialise ( oSettings )
10 var i, iLen, iAjaxStart=oSettings.iInitDisplayStart;
12 /* Ensure that the table data is fully initialised */
13 if ( oSettings.bInitialised === false )
15 setTimeout( function(){ _fnInitialise( oSettings ); }, 200 );
19 /* Show the display HTML options */
20 _fnAddOptionsHtml( oSettings );
22 /* Build and draw the header / footer for the table */
23 _fnBuildHead( oSettings );
24 _fnDrawHead( oSettings, oSettings.aoHeader );
25 if ( oSettings.nTFoot )
27 _fnDrawHead( oSettings, oSettings.aoFooter );
30 /* Okay to show that something is going on now */
31 _fnProcessingDisplay( oSettings, true );
33 /* Calculate sizes for columns */
34 if ( oSettings.oFeatures.bAutoWidth )
36 _fnCalculateColumnWidths( oSettings );
39 for ( i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
41 if ( oSettings.aoColumns[i].sWidth !== null )
43 oSettings.aoColumns[i].nTh.style.width = _fnStringToCss( oSettings.aoColumns[i].sWidth );
47 /* If there is default sorting required - let's do it. The sort function will do the
48 * drawing for us. Otherwise we draw the table regardless of the Ajax source - this allows
49 * the table to look initialised for Ajax sourcing data (show 'loading' message possibly)
51 if ( oSettings.oFeatures.bSort )
55 else if ( oSettings.oFeatures.bFilter )
57 _fnFilterComplete( oSettings, oSettings.oPreviousSearch );
61 oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
62 _fnCalculateEnd( oSettings );
66 /* if there is an ajax source load the data */
67 if ( oSettings.sAjaxSource !== null && !oSettings.oFeatures.bServerSide )
70 _fnServerParams( oSettings, aoData );
71 oSettings.fnServerData.call( oSettings.oInstance, oSettings.sAjaxSource, aoData, function(json) {
72 var aData = (oSettings.sAjaxDataProp !== "") ?
73 _fnGetObjectDataFn( oSettings.sAjaxDataProp )(json) : json;
75 /* Got the data - add it to the table */
76 for ( i=0 ; i<aData.length ; i++ )
78 _fnAddData( oSettings, aData[i] );
81 /* Reset the init display for cookie saving. We've already done a filter, and
82 * therefore cleared it before. So we need to make it appear 'fresh'
84 oSettings.iInitDisplayStart = iAjaxStart;
86 if ( oSettings.oFeatures.bSort )
92 oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
93 _fnCalculateEnd( oSettings );
97 _fnProcessingDisplay( oSettings, false );
98 _fnInitComplete( oSettings, json );
103 /* Server-side processing initialisation complete is done at the end of _fnDraw */
104 if ( !oSettings.oFeatures.bServerSide )
106 _fnProcessingDisplay( oSettings, false );
107 _fnInitComplete( oSettings );
113 * Draw the table for the first time, adding all required features
114 * @param {object} oSettings dataTables settings object
115 * @param {object} [json] JSON from the server that completed the table, if using Ajax source
116 * with client-side processing (optional)
117 * @memberof DataTable#oApi
119 function _fnInitComplete ( oSettings, json )
121 oSettings._bInitComplete = true;
122 _fnCallbackFire( oSettings, 'aoInitComplete', 'init', [oSettings, json] );
127 * Language compatibility - when certain options are given, and others aren't, we
128 * need to duplicate the values over, in order to provide backwards compatibility
129 * with older language files.
130 * @param {object} oSettings dataTables settings object
131 * @memberof DataTable#oApi
133 function _fnLanguageCompat( oLanguage )
135 var oDefaults = DataTable.defaults.oLanguage;
137 /* Backwards compatibility - if there is no sEmptyTable given, then use the same as
138 * sZeroRecords - assuming that is given.
140 if ( !oLanguage.sEmptyTable && oLanguage.sZeroRecords &&
141 oDefaults.sEmptyTable === "No data available in table" )
143 _fnMap( oLanguage, oLanguage, 'sZeroRecords', 'sEmptyTable' );
146 /* Likewise with loading records */
147 if ( !oLanguage.sLoadingRecords && oLanguage.sZeroRecords &&
148 oDefaults.sLoadingRecords === "Loading..." )
150 _fnMap( oLanguage, oLanguage, 'sZeroRecords', 'sLoadingRecords' );