Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (bUsePassedData) {
- for (var i = 0, len = oInit.aaData.length; i < len; i++) {
- _fnAddData(oSettings, oInit.aaData[i]);
- }
- } else if (oSettings.bDeferLoading ||
- (oSettings.sAjaxSource === null && oSettings.ajax === null)) {
- _fnAddTr(oSettings, $(oSettings.nTBody).children('tr'));
- }
- (oSettings.sAjaxSource === null && oSettings.ajax === null) // true
- function beforeIf(){
- if (bUsePassedData) {
- procesData(oSettings,oInit.aaData.concat());
- } else if (oSettings.bDeferLoading ||
- (oSettings.sAjaxSource === null && oSettings.ajax === null)) {
- _fnAddTr(oSettings, $(oSettings.nTBody).children('tr'));
- }
- afterIF();
- }
- function processData(oSettings,arr){
- //process in chuncks of 50;
- // setTimeout takes a long time in IE
- // it'll noticibly slow donw your script when
- // only processing one item at the time
- var tmp=arr.splice(0,50);
- for (var i = 0, len = tmp.length; i < len; i++) {
- _fnAddData(oSettings, tmp[i]);
- }
- if(arr.length!==0){
- setTimeout(function(){
- processData(oSettings,arr);
- },0);
- return;
- }
- afterIf();
- }
- function afterIf(){
- //continue processing
- }
- (function processData(oSettings, arr) {
- var tmp = arr.splice(0, 50);
- tickApp.$orders.dataTable().fnAddData(tmp);
- if (arr.length !== 0) {
- setTimeout(function () {
- processData(oSettings, arr);
- }, 0);
- }
- }(oSettings, oInit.aaData.concat()));
- tickApp.$orders = $('#orders');
- var DEFAULT_CHUNK_SIZE = 200;
- function feedDataToDataTableInChunks(data, oSettings) {
- var chunk = data.splice(0, DEFAULT_CHUNK_SIZE);
- oSettings.oInstance.fnAddData(chunk, false);
- if(data.length !== 0) {
- setTimeout(function () {
- feedDataToDataTableInChunks(data, oSettings);
- });
- } else {
- oSettings.oInstance.fnDraw();
- }
- }
- var config = {fnServerData: function(){
- oSettings.jqXHR = $.getJSON(sSource, aoData)
- .done(function (result) {
- feedDataToDataTableInChunks(result || [], oSettings);
- });
- }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement