Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 81669

How to check checkboxes on filtered rows?

$
0
0
I have a single checkbox in the thead TR and every tbody TR. The ones in the tbody are for individual selection, but I want the checkbox in the thead to check all visible (also on other pages) row checkboxes. So if I filter it, check the checkbox in the thead it only needs to select the affected rows.

I have this as you could suspect:

	$('.dataTable input.selectAll').click(function(){

		if($(this).prop('checked')==false){
			$('input', oTable.fnGetNodes()).prop('checked',false);
		}
		else{
			$('input', oTable.fnGetNodes()).prop('checked',true);
		}
		
	})

This checks every single checkbox, even when they are hidden after a search filter.

After a lot of searching I figured the function fnGetFilteredNodes would have been perfect for me, but apparently it's redundant according to http://www.datatables.net/forums/discussion/comment/37013#Comment_37013. The right method would be by using:

table._('tr', {"filter":"applied"});

This returns arrays of data of every single rows' cell, but I have no idea how to check the affected rows checkboxes. Could anyone help me out?

Viewing all articles
Browse latest Browse all 81669

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>