我正在使用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' }
]
});
Run Code Online (Sandbox Code Playgroud)
我知道我可以通过我给它的名字从表中获取列,但我似乎无法找到如何从列对象中找到列的名称.(我希望可以使用组件的当前状态.)例如:
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'
});
Run Code Online (Sandbox Code Playgroud)
获得这个名字的正确功能或属性是什么?