Quantcast
Channel: DataTables 1.9 — DataTables forums
Viewing all articles
Browse latest Browse all 1816

StateSave being fired immediately after page load

$
0
0
When using server side processing, a call to State Save fires twice during DT loading. Here is a screenshot.
http://i.imgur.com/lSOk28S.jpg

NOTE: I was unable to use the debug bookmark due to a mixed content warning in Firefox or IE 11.

Here is my DT definition:
	var oDTSettings = {
		//"aoColumns": aoColumns,
		"aoColumnDefs": aoColumnDefs,
		//"aaSorting": <?php echo $aaSorting; ?>,
		"sScrollX": "100%", // Required
		"sScrollY": "400px", // Setting to auto or 100% introduces column glitches
		"sPaginationType": "full_numbers",
        "sAjaxSource": '<?php echo MOD_URL.CLASS_NAME."/?event=filterAjax";?>',
		"sDom": '<"dt-header"l<"dt-breadcrumb">f>t<"dt-footer"i<"dt-selected">rp<"dt-textsize">>',

		"iDisplayLength": 100,
		"aLengthMenu": [50,100,250,500],
		
		"bAutoWidth": false,
		"bStateSave": true,
		"bDeferRender": true,
		"bProcessing": true,
        "bServerSide": true,
		"oLanguage": {
			"sSearch": "Search Within:",
			"sEmptyTable": "No matching Work Orders found",
			"sProcessing": "Loading..."
		},

		"fnCreatedRow": fnCreatedRow,
		//"fnRowCallback": fnRowCallback,
		"fnDrawCallback": fnDrawCallback,
		"fnPreDrawCallback": fnPreDrawCallback,
		"fnInitComplete": fnInitComplete,
		"fnCreatedCell": fnCreatedCell,
		"fnStateSave": fnStateSave,
		"fnStateLoad": fnStateLoad
	};
	
	<?php if (!$grouped){ ?>
	var oTable = jq('#work_orders').dataTable(oDTSettings);
	//console.log(oTable.fnSettings());
	
	<?php if ($freeze_icons_column){ ?>
	var oFixedOptions = {
		"fnRowCallback": '',
		"fnDrawCallback": fnPluginDrawCallback,
		"iLeftColumns": 0,
		"sHeightMatch": "none"
	}
	
	// If the last column is icons, apply the fixed column plugin
	if(window.aoColumnDefs[window.aoColumnDefs.length-1].mData == "icons"){		
		oFixedOptions.iRightColumns = 1;
	}
	
	// Don't render on IE8 or below
	if (!(jq.browser.msie && jq.browser.version <= '8')){
		//new FixedColumns( oTable, oFixedOptions);
		new jq.fn.dataTable.FixedColumns(oTable, oFixedOptions);
	}
	<?php } ?>
	
	<?php } ?>


And here is the state load/save callbacks:
function fnStateSave(oSettings, oData) {
	// Send an Ajax request to the server with the state object
	jq.ajax({
		"url": '<?php echo MOD_URL.CLASS_NAME."/?event=stateSave";?>',
		"data": oData,
		"dataType": "json",
		"method": "POST",
		"success": function () {}
	});
}

function fnStateLoad(oSettings) {
	var o;
	
	// Send an Ajax request to the server to get the data. Note that
	// this is a synchronous request.
	jq.ajax({
		"url": '<?php echo MOD_URL.CLASS_NAME."/?event=stateLoad";?>',
		"async": false,
		"dataType": "json",
		"success": function (json) {
		o = json;
		}
	});
	
	return o;
}


Viewing all articles
Browse latest Browse all 1816

Trending Articles