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

Fixed: When infinite scrolling, DataTables would clear it's internal cache of rows on every draw, when server-side processing was being used. This could result in fnGetNodes giving only a subset of the nodes which are visible, rather than the full set (which it now does).

This commit is contained in:
Allan Jardine 2010-09-15 10:29:03 +01:00
parent 0b8b2f7eea
commit 7f04b7ffb5
3 changed files with 149 additions and 4 deletions

View File

@ -3189,7 +3189,11 @@
}
}
_fnClearTable( oSettings );
if ( !oSettings.oScroll.bInfinite ||
(oSettings.oScroll.bInfinite && (oSettings.bSorted || oSettings.bFiltered)) )
{
_fnClearTable( oSettings );
}
oSettings._iRecordsTotal = json.iTotalRecords;
oSettings._iRecordsDisplay = json.iTotalDisplayRecords;

View File

@ -21,6 +21,12 @@ $(document).ready( function () {
);
oTest.fnTest(
"Get nodes",
null,
function () { return $('#example tbody>tr').length == 10; }
);
oTest.fnWaitTest(
"Scroll on 20px adds 10 rows",
function () { $('div.dataTables_scrollBody').scrollTop(20); },
function () { return $('#example tbody tr').length == 20; }
@ -32,6 +38,12 @@ $(document).ready( function () {
function () { return $('#example_info').html() == "Showing 1 to 20 of 57 entries"; }
);
oTest.fnTest(
"Get nodes after 20px scroll",
null,
function () { return $('#example tbody>tr').length == 20; }
);
oTest.fnTest(
"Scroll on 10px more results in the same number of rows",
function () { $('div.dataTables_scrollBody').scrollTop(30); },
@ -44,7 +56,7 @@ $(document).ready( function () {
function () { return $('#example_info').html() == "Showing 1 to 20 of 57 entries"; }
);
oTest.fnTest(
oTest.fnWaitTest(
"Scroll to 240px adds another 10 rows",
function () { $('div.dataTables_scrollBody').scrollTop(240); },
function () { return $('#example tbody tr').length == 30; }
@ -56,9 +68,18 @@ $(document).ready( function () {
function () { return $('#example_info').html() == "Showing 1 to 30 of 57 entries"; }
);
oTest.fnTest(
"Get nodes after 240px scroll",
null,
function () { return $('#example tbody>tr').length == 30; }
);
oTest.fnTest(
"Filtering will drop back to 10 rows",
function () { oTable.fnFilter('gec') },
function () {
$('div.dataTables_scrollBody').scrollTop(0);
oTable.fnFilter('gec')
},
function () { return $('#example tbody tr').length == 10; }
);
@ -69,23 +90,41 @@ $(document).ready( function () {
);
oTest.fnTest(
"Get nodes after filtering",
null,
function () { return $('#example tbody>tr').length == 10; }
);
oTest.fnWaitTest(
"Scroll after filtering adds 10",
function () { $('div.dataTables_scrollBody').scrollTop(20); },
function () { return $('#example tbody tr').length == 20; }
);
oTest.fnTest(
"Get nodes after filtering",
null,
function () { return $('#example tbody>tr').length == 20; }
);
oTest.fnTest(
"Sorting will drop back to 10 rows",
function () { oTable.fnSort([[1,'asc']]) },
function () { return $('#example tbody tr').length == 10; }
);
oTest.fnTest(
oTest.fnWaitTest(
"Scroll after sorting adds 10",
function () { $('div.dataTables_scrollBody').scrollTop(20); },
function () { return $('#example tbody tr').length == 20; }
);
oTest.fnTest(
"Get nodes after scrolling",
null,
function () { return $('#example tbody>tr').length == 20; }
);
oTest.fnComplete();
} );

View File

@ -16,36 +16,126 @@ $(document).ready( function () {
function () { return $('#example tbody tr').length == 10; }
);
oTest.fnTest(
"Info",
null,
function () { return $('#example_info').html() == "Showing 1 to 10 of 57 entries"; }
);
oTest.fnTest(
"Get nodes",
null,
function () { return $('#example tbody>tr').length == 10; }
);
oTest.fnTest(
"Get nodes function",
null,
function () { return $('#example').dataTable().fnGetNodes().length == 10; }
);
oTest.fnWaitTest(
"Scroll on 20px adds 10 rows",
function () { $('div.dataTables_scrollBody').scrollTop(20); },
function () { return $('#example tbody tr').length == 20; }
);
oTest.fnTest(
"Info after 20px scroll",
null,
function () { return $('#example_info').html() == "Showing 1 to 20 of 57 entries"; }
);
oTest.fnTest(
"Get nodes after 20px scroll",
null,
function () { return $('#example tbody>tr').length == 20; }
);
oTest.fnTest(
"Get nodes function after 20px scroll",
null,
function () { return $('#example').dataTable().fnGetNodes().length == 20; }
);
oTest.fnWaitTest(
"Scroll on 10px more results in the same number of rows",
function () { $('div.dataTables_scrollBody').scrollTop(30); },
function () { return $('#example tbody tr').length == 20; }
);
oTest.fnTest(
"Info after 10 more px scroll",
null,
function () { return $('#example_info').html() == "Showing 1 to 20 of 57 entries"; }
);
oTest.fnWaitTest(
"Scroll to 240px adds another 10 rows",
function () { $('div.dataTables_scrollBody').scrollTop(240); },
function () { return $('#example tbody tr').length == 30; }
);
oTest.fnTest(
"Info after 240px scroll",
null,
function () { return $('#example_info').html() == "Showing 1 to 30 of 57 entries"; }
);
oTest.fnTest(
"Get nodes after 240px scroll",
null,
function () { return $('#example tbody>tr').length == 30; }
);
oTest.fnTest(
"Get nodes function after 240px scroll",
null,
function () { return $('#example').dataTable().fnGetNodes().length == 30; }
);
oTest.fnWaitTest(
"Filtering will drop back to 10 rows",
function () { oTable.fnFilter('gec') },
function () { return $('#example tbody tr').length == 10; }
);
oTest.fnTest(
"Info after filtering",
null,
function () { return $('#example_info').html() == "Showing 1 to 10 of 20 entries (filtered from 57 total entries)"; }
);
oTest.fnTest(
"Get nodes after filtering",
null,
function () { return $('#example tbody>tr').length == 10; }
);
oTest.fnTest(
"Get nodes function after filtering",
null,
function () { return $('#example').dataTable().fnGetNodes().length == 10; }
);
oTest.fnWaitTest(
"Scroll after filtering adds 10",
function () { $('div.dataTables_scrollBody').scrollTop(20); },
function () { return $('#example tbody tr').length == 20; }
);
oTest.fnTest(
"Get nodes after filtering",
null,
function () { return $('#example tbody>tr').length == 20; }
);
oTest.fnTest(
"Get nodes function after filtering",
null,
function () { return $('#example').dataTable().fnGetNodes().length == 20; }
);
oTest.fnWaitTest(
"Sorting will drop back to 10 rows",
function () { oTable.fnSort([[1,'asc']]) },
@ -58,6 +148,18 @@ $(document).ready( function () {
function () { return $('#example tbody tr').length == 20; }
);
oTest.fnTest(
"Get nodes after scrolling",
null,
function () { return $('#example tbody>tr').length == 20; }
);
oTest.fnTest(
"Get nodes function after scrolling",
null,
function () { return $('#example').dataTable().fnGetNodes().length == 20; }
);
oTest.fnComplete();
} );