1
0
mirror of https://github.com/DataTables/DataTables.git synced 2025-01-30 23:52:11 +01:00

Fixed: State saving when there were no column being sorted was broken - 2914

This commit is contained in:
Allan Jardine 2010-09-30 20:18:33 +01:00
parent 2315bf3635
commit 81107d0b7d
3 changed files with 44 additions and 4 deletions

View File

@ -14,7 +14,8 @@
<script type="text/javascript" charset="utf-8"> <script type="text/javascript" charset="utf-8">
$(document).ready(function() { $(document).ready(function() {
$('#example').dataTable( { $('#example').dataTable( {
"bStateSave": true "bStateSave": true,
"aaSorting": []
} ); } );
} ); } );
</script> </script>

View File

@ -5752,7 +5752,7 @@
sValue += '"sFilter":"'+ encodeURIComponent(oSettings.oPreviousSearch.sSearch)+'",'; sValue += '"sFilter":"'+ encodeURIComponent(oSettings.oPreviousSearch.sSearch)+'",';
sValue += '"sFilterEsc":'+ !oSettings.oPreviousSearch.bRegex+','; sValue += '"sFilterEsc":'+ !oSettings.oPreviousSearch.bRegex+',';
sValue += '"aaSorting":['; sValue += '"aaSorting":[ ';
for ( i=0 ; i<oSettings.aaSorting.length ; i++ ) for ( i=0 ; i<oSettings.aaSorting.length ; i++ )
{ {
sValue += '['+oSettings.aaSorting[i][0]+',"'+oSettings.aaSorting[i][1]+'"],'; sValue += '['+oSettings.aaSorting[i][0]+',"'+oSettings.aaSorting[i][1]+'"],';
@ -5760,7 +5760,7 @@
sValue = sValue.substring(0, sValue.length-1); sValue = sValue.substring(0, sValue.length-1);
sValue += "],"; sValue += "],";
sValue += '"aaSearchCols":['; sValue += '"aaSearchCols":[ ';
for ( i=0 ; i<oSettings.aoPreSearchCols.length ; i++ ) for ( i=0 ; i<oSettings.aoPreSearchCols.length ; i++ )
{ {
sValue += '["'+encodeURIComponent(oSettings.aoPreSearchCols[i].sSearch)+ sValue += '["'+encodeURIComponent(oSettings.aoPreSearchCols[i].sSearch)+
@ -5769,7 +5769,7 @@
sValue = sValue.substring(0, sValue.length-1); sValue = sValue.substring(0, sValue.length-1);
sValue += "],"; sValue += "],";
sValue += '"abVisCols":['; sValue += '"abVisCols":[ ';
for ( i=0 ; i<oSettings.aoColumns.length ; i++ ) for ( i=0 ; i<oSettings.aoColumns.length ; i++ )
{ {
sValue += oSettings.aoColumns[i].bVisible+","; sValue += oSettings.aoColumns[i].bVisible+",";
@ -5778,6 +5778,7 @@
sValue += "]"; sValue += "]";
sValue += "}"; sValue += "}";
_fnCreateCookie( oSettings.sCookiePrefix+oSettings.sInstance, sValue, _fnCreateCookie( oSettings.sCookiePrefix+oSettings.sInstance, sValue,
oSettings.iCookieDuration, oSettings.sCookiePrefix, oSettings.fnCookieCallback ); oSettings.iCookieDuration, oSettings.sCookiePrefix, oSettings.fnCookieCallback );
} }

View File

@ -0,0 +1,38 @@
// DATA_TEMPLATE: dom_data
oTest.fnStart( "2914 - State saving with an empty array" );
$(document).ready( function () {
document.cookie = "";
$('#example').dataTable( {
"bStateSave": true,
"aaSorting": []
} );
oTest.fnTest(
"No sort",
null,
function () { return $('#example tbody td:eq(3)').html() == "4"; }
);
oTest.fnTest(
"Next page",
function () {
$('#example').dataTable().fnPageChange( 'next' );
},
function () { return $('#example tbody td:eq(1)').html() == "Camino 1.0"; }
);
oTest.fnTest(
"Destroy the table and remake it - checking we are still on the next page",
function () {
$('#example').dataTable( {
"bStateSave": true,
"aaSorting": [],
"bDestroy": true
} );
},
function () { return $('#example tbody td:eq(1)').html() == "Camino 1.0"; }
);
oTest.fnComplete();
} );