Datatables filter numbers greater than

I am using datables, I need to filter particular column whose values are greater than 50 , I tried below code , but nothing happens

oTable.api().column( 10 )
  .filter( function ( value, index ) {
     var htmlObject = $(value);
     var ball = htmlObject.text();
     return parseInt(ball) > 50 ? true : false;



If you want to check any number greater than 5 then you can write ternary conditional with the hidden column in dataTable. Using filter add MORETHAN5RECORD as a value in the select dropdown to filter greater than 5 records.

Here is the Code :
var table = $('#record_table').DataTable({});
$('.FILTERCLASS').on('keyup change', function () {
function buildFilters(table, element){					
    var type = $(element).data('type'),
        col = $(element).data('col'),
        id = $(element).id;   
          .column( col )
          .search( element.value )
echo (($row['xyz'] >= 5) ? $val['xyz']."(MORETHAN5RECORD)" : $val['xyz']); ?> </td> 


"Nothing happens" because nothing is expected to happen. filter() should be used to create internal datasets or extract subsets of data - if you want to filter the rows in the table you should use a custom filter. It could look like this :

$, data, dataIndex) {
  return data[10] > 50 //type conversion is not necessary

This works as a "master" filter before .search() (and other filters). If you want to remove the filter you can use $ So

  1. $ filter function )
  2. table.draw()
  3. $


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.