How do I access columns.data inside of defaultContent
How do I access columns.data inside of defaultContent
I am trying to set some buttons id's to the last element in each row in data(id). My JS code is
```js
$('#student_dash_tbl_1').dataTable( {
"processing": true,
"ajax": "/datatable_3",
"columns" : [
{'data':'0'},
{'data':'1'},
{'data':'2'},
{
data: null,
className: "center",
sortable: false,
defaultContent: '<a id="rollover_"''+data.id+'this.columns.data.id+' class="btn btn-success" role="button">Rollover</a>'
},
{
data: null,
className: "center",
sortable: false,
defaultContent: '<a class="btn btn-warning" role="button">Withdraw</a>'
},
{
data: null,
className: "center",
sortable: false,
defaultContent: '<a class="btn btn-danger" role="button">Delete</a>'
},
{
data: null,
className: "center",
sortable: false,
defaultContent: '<a class="btn btn-info" role="button">Reset</a>'
},
]
});
and an example of the data being returned to the AJAX is
[23-Sep-2014 15:38:47 UTC] Array
(
[0] => Array
(
[0] => Snow, Jon
[1] => 3
[2] => Archway Cicero
[id] => 3
)
[1] => Array
(
[0] => Targaryen, Daenerys
[1] => 3
[2] => Archway Scottsdale
[id] => 2
)
)
Any help would be appreciated.
This question has an accepted answers - jump to answer
Answers
UPDATE:
Rather then using defaultContent I switched it to render.
```
That is the correct thing to do.
columns.defaultContent
is static and therefore cannot possibly access the data.Allan