Get Column Names from Datatable

Get Column Names from Datatable

srgsrg Posts: 3Questions: 0Answers: 0
edited April 2014 in DataTables 1.10
We are using dataTables 1.10, and we want to get an array of columns in a dataTable and their names. We want to append those names to a [code][/code] element.

Here is what we have so far:

[code]
/**
* Add individual option elements for each column in full table
*/
FullTable.prototype.initColumnFilter = function () {
if (this.$columnFilter.length > 0) { // if the selector works...
var tableColumns = this.$tableContainer.dataTable().api().columns(),
html;
for (var i = 0; i < tableColumns.length; i++) {
html += '' + i + tableColumns[i].sTitle + '';
}
var $columnSelect = this.$columnFilter.find("#tableColumnFilter").append(html);
}
}
[/code]

This will output [code]0undefined[/code] as the only option element in the select.

Thanks in advance.
This discussion has been closed.