Get column name by index
Get column name by index
UdiD
Posts: 16Questions: 7Answers: 1
Is there a way to get a column name (i.e., the name defined using columns.name
option), which is more direct than the following one?
var exampleIndex = 3;
var columnName = table.settings().init().columns[exampleIndex].name;
This discussion has been closed.
Answers
i typically declare my columns separate so I can access that information, something like
var cols = null;
$(document).ready(function(){
cols = [{}, {}, {}]
})
This is something that will be added in DataTables 2. There isn't an API for getting the name in 1.x I'm afraid.
v2 won't be launching until sometime next year before you ask . I'm not sure when - there is still a lot of work to do on it!
Until then, I would suggest wrapping your code up into a plug-in API method.
Allan