2016-03-06 70 views
1

某些行我也用ajax作为数据源的数据表,还我有一个数组包含几个ROW_ID,我想显示其行ROW_ID是不是该数组英寸如何隐藏在数据表

我该怎么办?

我有搜索数据表文档,并尝试了多种功能/回调,他们都没有工作。

回答

1

你可以很轻松地设置一个custom filter永久排除(或隐藏)的某些行的任何标准后,你想:

var excluded_row_ids = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43] 

$.fn.dataTable.ext.search.push(function(settings, data, dataIndex) { 
    //assuming the row_id is located in first column 
    return (!~excluded_row_ids.indexOf(parseInt(data[0]))) 

    //or for example compare to dataIndex, i.e. original insert order 
    //return (!~excluded_row_ids.indexOf(dataIndex)) 
}) 

如果您由于某种原因要包含的那些行,只需取下过滤网:

$.fn.dataTable.ext.search.pop() 

演示 - >http://jsfiddle.net/pcwf6tuh/