Get Array/List of Column names

Get Array/List of Column names

jchannonjchannon Posts: 26Questions: 0Answers: 0
edited October 2011 in General
Hi!

I would like to return an array of the columns with their names in it. I couldn't see an API call to do this so I thought about using this:

[code]

var cols = $('th');
var colnames = [];

$.each(cols, function() {
colnames.push($(this).text());
});

[/code]

Thanks

Replies

  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    Yup - sounds good :-). There isn't an API call currently that will do this, but your function above covers it (although not hidden columns if anyone want's that functionality). It could readily be wrapped up into an API plug-in method as described here: http://datatables.net/blog/Creating_feature_plug-ins

    Allan
This discussion has been closed.