Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82249

getting custom data attributes with data

$
0
0

Hi

I just updated to DataTables version 2 from version 1.

Earlier when calling row().data() the data retrieved was an json object and keys was either the data-data attribute on the th or the index.

example:
html: ".....<th></th><th datat-data='template'></th>....."
calling row().data() returned: {"0":"<div>...</div>", "template":"<div>....</div>"}

version 2 returns an array of columns data, but i now miss the identifier "template" that i used earlier to get the specific data i needed.

example:
html: ".....<th></th><th datat-data='template'></th>....."
calling row().data() returns: ["<div>...</div>", "<div>....</div>"]

is it possible to set a custom data attribute on the tr or th, so i can identify the given column i wish to get the data from, something like the data-sort attribute is included in the array object.

example:
html: ".....<th></th><th datat-data='template'></th>.....<td data-sort='test'>...</td>"
calling row().data() returns: ["<div>...</div>", {"display":""<div>...</div>"","@data-sort":"test"}]

reference: https://datatables.net/reference/api/row().data()

kind regards
cbb


Viewing all articles
Browse latest Browse all 82249

Trending Articles