Added 'oData._aData.DT_RowData' to set <tr> HTML5 'data-*' custom attributes #45

wants to merge 1 commit into from

2 participants


A more generic way to set non-data properties could be jQuery's $(<tr>).prop(oData) function.


This is quite a nice idea (although note that changes should be made in the media/src directory since jquery.dataTables.js is now a generated file :-) ). However, what is the benefit of doing this over simply access the data (DT_RowData) through fnGetData (or the new _ function in 1.9)? It looks like it be basically doing the same thing, but a slightly different method (this way is perhaps more "jQuery" like).


I forgot to mention that my commit would be useful to set <tr> (data-)properties with an AJAX server response.
It would be also useful to have a mean to set <td> (data-)properties by the server response.
I don't know the new _ function in 1.9, I'll give it a look!


In fairness the new _ function is really new (it will be in beta 3 :-) ). It is basically the same as the $ function ($ ) but gives the data object for a row rather than the node.

Does the jQuery data method also set the data- properties? I think I need to read up a bit more about what this provides, but I do like the look of it :-)



I was unclear again! The jQuery data method gives access to the jQuery-element's data object, but initializes it by reading HTML5 data-* properties; thus, it doesn't modify the markup. To add actual data-* properties we could use the prop method.


Been thinking about this a fair bit recently, and I don't think I'm going to include it just yet, due to the fact that it is duplicating (to some extent) the internal data store that DataTables uses and the fnGetData / _ functions. However, I am very much open to introducing this in future if there is a benefit over the fnGetData / _ functions or there are a couple of other requests for it.

Leaving the issue open for the moment to allow others to comment on it.


I understand, it's okay! Thank you for thinking about it for a while. Right now I'm using this approach to send <tr> properties in the JSON response, do you have any suggestion on doing that with fnGetData/_ functions?


Quick update: Considering this for DataTables 1.10. Depends a little bit on how I get on with using attributes for sorting.

Until then, in answer to the last question (really sorry about the massive delay) - you can use orthogonal data as described here:

@DataTables DataTables referenced this pull request Sep 16, 2012

additional information #7

@DataTables DataTables added a commit that referenced this pull request May 26, 2013
@DataTables New: HTML5 data-* attributes for the TR can be set using DT_RowData

- Extending the funtionality of DT_RowId and DT_RowClass, this commit
  adds DT_RowData which utalises jQuery's `$().data()` method to set
  HTML5 data-* attributes, which can be useful for additional meta data.

- This is some what complimentary to using objects as the data source
  where you could just use row().data() to get the data, but this is
  effectively an orthogonal way of getting the data and might be useful
  for existing Javascript libraries.

- It should be noted that the data-sort and data-filter work I'll be
  doing for v1.10 shortly will not interact with this method, that will
  be DOM sourced data only, while this is Ajax / Javascript based only.
  However, if you do want to use data from this source for filtering /
  sorting, its easy to do with `data` - `data: 'DT_RowData.sort'` for

- This fixes issue #45.

I've finally got around to adding this, exactly as is in 20949ae which will be released as part of v1.10. This is part of DataTable's move to be able to make more use of HTML5 as part of v1.10 :-).

Thanks for the request for this to be added! I might not be the quickest, but I do get there :-)

@DataTables DataTables closed this May 26, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment