数据表 - 根据其他列数据获取列数据

时间:2016-05-26 13:02:56

标签: javascript jquery datatables

我有这种格式的表格

c1    c2     c3      c4

1   True    row1   row1c4
2   True    row2   row2c4
3   False   row3   row3c4
4   False   row4   row4c4

我用它来过滤掉col 4数据

var table = $('#statustable').DataTable();
var emaillist =
            table
                .columns('c4:name')
                .data()
                .eq( 0 )      // Reduce the 2D array into a 1D array of data
                .unique()     // Reduce to unique values
                .sort()       // Sort data alphabetically               
                .join( ',' );

现在我需要在c4时根据c2过滤掉c2 is true列?

有人可以指导我吗?

1 个答案:

答案 0 :(得分:1)

无法访问JSFiddle我创建了这个:

var table = $('#example').DataTable();
emailList = [];
table.rows().eq(0).each(function(index){
    var row = table.row(index);
    var data = row.data();
    (data[1] === "True" && emailList.indexOf(data[3]) === -1) && emailList.push(data[3]);
    return data[3];
});
console.log(emailList.join());

工作here。希望有所帮助。