Use of column.name instead of index does not seem to work
Use of column.name instead of index does not seem to work
sronsiek
Posts: 52Questions: 11Answers: 0
I have set up names in my columnDefs as suggested:
"columnDefs": [
{ "name": 'group', "targets": [ 0 ] },
{ "name": 'user', "targets": [ 1 ] },
{ "name": 'comment', "targets": [ 2 ] },
I now want to use these instead of column indices to make
code more readable (which I thought was the purpose of the feature):
var api = oTable.api()
api.rows().eq(0).each( function( idx )
{
var row_data = api.row( idx ).data()
At this point however, data.group, data.user and data.comment are all undefined,
while data[0], data[1], data[2] are populated.
Have I missed something?
This discussion has been closed.
Replies
DataTables currently does not convert from array format into object format (when reading from the DOM). It is a feature that I will add in future (hopefully not to far away), but currently it does not exist.
The
columns.name
option is for the API so you can use it as part of a selector - for exampletable.column( 'group:name' ).data()
rather than using an index.Allan