get column names along with row data
get column names along with row data
vismark
Posts: 79Questions: 5Answers: 0
Hi...when retrieving row data through elm.row(elm.closest('tr')).data()
method, how can I get column names too? Consider they might have been reordered through reorder plugin. I will need an object like this: {"col1":"aaa","col2":"bbb"}
rather than ["aaa","bbb"]
that I'm getting now.
Replies
Use
columns().header()
withto$()
to create a jQuery object you can loop through with jQuery each(). In the loop build the object you want for the columns. Here is an example with colReorder:http://live.datatables.net/dokukozi/1/edit
Kevin
Hi Kevin, thanks. Th eexample you linked doesn't open. BTW, this is just retrieving the actual HTML in page...isn't there a more official way to get the column internal names in the correct order?
The link does work. Your browser is probably trying to use SSL by changing HTTP to HTTPS which won't work. Try another browser or make sure the URL has just HTTP.
See if this plugin works for you.
Kevin