Text click GREATER THAN 0 and LESS THAN 0 filter?
Text click GREATER THAN 0 and LESS THAN 0 filter?
OnaksGaraj
Posts: 1Questions: 1Answers: 0
I want to create custom filter for greater or less than 0 from clicked text link.
$.fn.dataTable.ext.search.push(
function( settings, data, dataIndex ) {
var balance = parseFloat( data[3] ) || 0; // use data for the balance column
if ( balance > 0 )
{
return true;
}
return false;
}
);
$(document).ready(function() {
var table = $('#example').DataTable();
$('#positiveBalance').on('click', function () {
table.draw();
});
} );
<a href="#" id="positiveBalance">Positive Balance</a>
I tired this code for Positive Balance but not work. How can I make it for positive and negative balance?
This discussion has been closed.
Answers
Glancing through your code it looks like it should work. However its hard to say without seeing your data, etc. Have you tried debugging the
data[3]
andbalance
values to see how the code works?Start by posting a link to your page or a test case replicating the issue so we can help debug.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin