No State Saving with $.fn.dataTableExt.afnFiltering.push

No State Saving with $.fn.dataTableExt.afnFiltering.push

milkcrownbabymilkcrownbaby Posts: 1Questions: 0Answers: 0
edited March 2012 in General
Hi all,

I have an XSL generated dropdown box to filter data by categories.
Everything is working fine, just the state saving for the custom column filter and the dropdown box is not working.

The data and the xsl template to build the table, the dropdown etc. ... is loaded by a php script with domDocument like this:

[code]
<?php
if (file_exists("blabla.xml")) {

/* load the xml file and stylesheet as domdocuments */
$xsl = new DomDocument();
$xsl->load("blabla.xsl");

$inputdom = new DomDocument();
$inputdom->preserveWhiteSpace=false;
$inputdom->load("blabla.xml");
$inputdom->save("blabla_2.xml");

/* create the processor and import the stylesheet */
$proc = new XsltProcessor();
$xsl = $proc->importStylesheet($xsl);

/* transform and output the xml document */
$newdom = $proc->transformToDoc($inputdom);
print $newdom->saveXML();

}
else {
exit("Error. ");
}
?>
[/code]


This is my code to build the dropdown box in the xsl template:

[code]

All Elements




[/code]

And my js code:

[code]
$.fn.dataTableExt.afnFiltering.push(
function ( oSettings, aData, iDataIndex ) {
var sID = $('select').val();
var sData = aData[0];
if (sID == sData)
{
return true;
}
else if (sID == "-1")
{
return true;
}
return false;
}
);

$(document).ready(function() {

var oTable = $('#example2').dataTable( {

"iDisplayLength": 25,
"aLengthMenu": [[10, 25, 50, -1], [10, 25, 50, "Alle"]],
"bStateSave": true,
"fnStateSave": function (oSettings, oData) { localStorage.setItem( 'DataTables_'+window.location.pathname, JSON.stringify(oData) ); },
"fnStateLoad": function (oSettings) { return JSON.parse( localStorage.getItem('DataTables_'+window.location.pathname) ); },
"aoColumnDefs": [ { "bVisible": false, "aTargets": [ 0 ] } ],
"sDom": '<"top"lfp<"clear">>rt<"bottom"lfp<"clear">>',
"sPaginationType": "full_numbers",
"oLanguage": {
"sUrl": "xxxxx/datatables_lang_de.txt",
"sSearch": "Search all columns:",
},
"fnInitComplete": function(oSettings, json) {
alert( 'DataTables has finished its initialisation.' );
}
} );

$('#sCat').change( function () {
oTable.fnDraw();
} );

} );
[/code]


Mhmmmm ....., hope somebody can help me out ;-)

Greetings

Michael

Replies

  • KA2012KA2012 Posts: 16Questions: 0Answers: 0
    Did you ever figure out how to save the state of custom filters? I've been struggling with trying to play around with aoPreSearchCols[i].sSearch, but looks like custom filter criteria doesn't get saved there.
This discussion has been closed.