【发布时间】:2015-12-12 10:20:31
【问题描述】:
我正在使用 DataTable 1.10.9(来自 https://datatables.net)。数据表的列是在 javascript 的初始化步骤中定义的,每列都有一个唯一的名称,例如:
var table = $('#example').DataTable({
columns: [
{ name: 'first-name' },
{ name: 'last-name' },
{ name: 'position' },
{ name: 'location' },
{ name: 'salary' }
]
});
我知道我可以通过我给它的名称从表中获取列,但我似乎无法找到如何从列对象中找到列的名称。 (我希望组件的当前状态是可能的。)例如:
table.columns().every(function() {
//I'd want to see what the name of this column is, something like:
console.log(this.name()); //will throw an exception since no such function exists
//or
console.log(this.name); //will output 'undefined'
});
获取名称的正确函数或属性是什么?
【问题讨论】:
标签: javascript jquery datatables