How to filterout the non related
How to filterout the non related
troshan
Posts: 2Questions: 1Answers: 0
I have a table which has columns 'client Name' and 'project name'. If I filter first column(client Name) by client name the second column(project name) filter need to be show only projects which related to the client which I selected. Right now it shows all the projects.
Here is my code. How can tweak this to meet my requirement?
$(document).ready(function() {
$('#tblclient').DataTable( {
initComplete: function () {
this.api().columns('.filter').every( function () {
var column = this;
var select = $('<select><option value="">--All--</option></select>')
.appendTo( $(column.footer()).empty() )
.on( 'change', function () {
var val = $.fn.dataTable.util.escapeRegex(
$(this).val()
);
column
.search( val ? '^'+val+'$' : '', true, false )
.draw();
} );
column.data().unique().sort().each( function ( d, j ) {
select.append( '<option value="'+d+'">'+d+'</option>' )
} );
} );
}
} );
} );
This discussion has been closed.
Answers
Follow the url for the test case
http://live.datatables.net/bemadapu
Allan had put together on demo on how to do this sort of thing already.
The link is here
http://live.datatables.net/xehimatu/1/edit