数据表过滤数字大于 [英] Datatables filter numbers greater than

查看:20
本文介绍了数据表过滤数字大于的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 数据表,我需要过滤值大于 50 的特定列,我尝试了以下代码,但什么也没有发生

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 )
  .data()
  .filter( function ( value, index ) {
     var htmlObject = $(value);
     var ball = htmlObject.text();
     return parseInt(ball) > 50 ? true : false;
   })
  .draw();

推荐答案

如果您想检查任何大于 5 的数字,那么您可以使用 dataTable 中的隐藏列编写三元条件语句.使用过滤器在选择下拉列表中添加 MORETHAN5RECORD 作为值以过滤超过 5 条记录.

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 () {
		buildFilters(table,this);
});	
	
function buildFilters(table, element){					
    var type = $(element).data('type'),
        col = $(element).data('col'),
        id = $(element).id;   
      table
          .column( col )
          .search( element.value )
          .draw();
    }

 <td><?php 
echo (($row['xyz'] >= 5) ? $val['xyz']."(MORETHAN5RECORD)" : $val['xyz']); ?> </td> 

这篇关于数据表过滤数字大于的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆