get column names along with row data

get column names along with row data

vismarkvismark 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

  • kthorngrenkthorngren Posts: 20,141Questions: 26Answers: 4,736

    Use columns().header() with to$() 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

  • vismarkvismark Posts: 79Questions: 5Answers: 0

    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?

  • kthorngrenkthorngren Posts: 20,141Questions: 26Answers: 4,736

    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

Sign In or Register to comment.