Update 1
Although I agree with rtruszk, I still think that a solution should be found / investigated if 0) you have no choice or 1) your client does not want to discuss UX changes.
Working example: http://jsfiddle.net/ebRXw/63/
I was able to accomplish what you need by filtering out the currently visible rows from the DataTable. I tried my best to find a solution in DataTables, and it may exist, but in the end I used jQuery and a hash table to identify and filter the currently visible rows.
I am sure that this can be optimized. Hope this makes you move in the right direction.
$(document).ready(function () { var table = $('#example').DataTable({ "columnDefs": [{ "targets": [0], "visible": false, "searchable": true }] }); // Show page 0 table.page(0).draw(false); // Sort by column 1 (Name) table.order([1, 'asc']).draw(false); $("#ReloadTable").click(function () { // Clear the current filter oTable = $('#example').dataTable(); oTable.fnFilter('', 0); oTable.fnFilter(''); // Reset all "visible" values in the first cell var table = $('#example').DataTable(); table.rows().indexes().each(function (idx) { var d = table.row(idx).data(); table.row(idx).data()[0] = 0; d.counter++; table.row(idx).data(d); }); }); $("#FilterCurrentPage").click(function () { // Create a hash of the index of currently visible rows var h = new Object(); var x = $('.odd,.even').filter(function () { var idx = $(this)[0]._DT_RowIndex; h[idx] = idx; return this.style.display == '' }); // update the first value based on the currently visible rows var table = $('#example').DataTable(); table.rows().indexes().each(function (idx) { var d = table.row(idx).data(); if (h.hasOwnProperty(idx)) { table.row(idx).data()[0] = 1; } d.counter++; table.row(idx).data(d); }); // filter rows with a value of 1 in the first cell oTable = $('#example').dataTable(); oTable.fnFilter(1, 0); }); });
Update 0
I still have not found a workaround, but I am convinced that it exists. The code below will select and return the current visible rows in your datatable.
var x = $('.odd,.even').filter(function () { $(this).addClass('selected');
In the DataTables support file :
Is there an easy way to tell datatables that I want to sort and redraw only the current pagination?
In DataTables 1.9- no, there is no way to do this, but in 1.10 you can use table.order (...). Draw (false); to save paging. 1.10 pre-beta is available in git if you want to give it bash :-)
Allan
via datatables: sort only the current pagination of the table
However, you can get the current visible lines, sort them and show them somehow. The code below provides the current visible lines after filtering.
var table = $('#example').DataTable(); table.$('tr', {"filter":"applied"});
See also: