这是一个相当容易的任务,如果它仅仅是如何计算的某些值的数量为特定列。你甚至可以实现它作为一个插件:
jQuery.fn.dataTable.Api.register('countValue()', function(index, value) {
var count = 0;
var data = this.data();
for (var d in data) {
if (data[d][index] == value) count++
}
return count;
});
现在你可以做
console.log('Developer', table.countValue(2, 'Developer'));
console.log('Regional Marketing', table.countValue(2, 'Regional Marketing'));
console.log('Software Engineer', table.countValue(2, 'Software Engineer'));
演示 - >http://jsfiddle.net/hmwLw2yw/
如果您使用的是JSON源,也可能是AJAX请求,请参阅项属性名称而不是数组索引:
console.log('Developer', table.countValue('position', 'Developer'));
console.log('Regional Marketing', table.countValue('position', 'Regional Marketing'));
console.log('Software Engineer', table.countValue('position', 'Software Engineer'));
演示 - >http://jsfiddle.net/ytw647ak/
你是如何拉动你的信息?为什么你不能这样做,而不是当你处理前端? – NoReceipt4Panda
它来自我无法控制的预定义报告 – pee2pee
您正在处理哪些语言?你打算用jQuery/js来做这件事吗? – NoReceipt4Panda