column().name()
column().name()
Yani
Posts: 24Questions: 7Answers: 0
I'm looking for a way to grab the name of a column.
The column().name() function seems perfect but isn't available until DataTables 2.0.0:
https://datatables.net/reference/api/column().name()
Does anybody know of a way to do this in 1.6.5?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Seems like using column().header() is the easiest workaround for this.
I have, in the past, declared my columns ahead of my data table so I could have full access to the information it contains.
I don't think that would have been usable in my case. When adding new rows, I'm selecting a specific column to be edited, but with colReorder the index was kind of useless.
did you know about the $("#example").DataTable().column( 'salary:name' ).data(); ?
https://datatables.net/reference/type/column-selector
Yes. I already selected the column, but needed the name.
The new
column().name()
method won't be available until v2 ships (unlikely to happen this year).If you wanted then before then, you could easily use them as plug-in API method. This is the code in DataTables core for them.
Allan
I haven't tested it, but this should do it:
Perfect! Thanks a lot Allan.