var response = [
{
"AttachmentUid": 0,
"AttachmentName": "AttachmentName",
"AttachmentType": "AttachmentType",
"CreatedOn": "CreatedOn",
"Printout": '<button class="btn" type="button">Click me</button>'
},
{
"AttachmentUid": 0,
"AttachmentName": "AttachmentName",
"AttachmentType": "AttachmentType",
"CreatedOn": "CreatedOn",
"Printout": '<button class="btn" type="button">Click me</button>'
},
{
"AttachmentUid": 0,
"AttachmentName": "AttachmentName",
"AttachmentType": "AttachmentType",
"CreatedOn": "CreatedOn",
"Printout": '<button class="btn" type="button">Click me</button>'
}
];
$(document).ready(function() {
initTable();
$('#example').on('click', '.btn', function(){
$.each(response, function(index, obj){
obj["AttachmentUid"]++;
});
initTable();
});
});
function initTable(){
var rnd = Math.floor((Math.random() * 10) + 1);
// Update footer headings
$('#example tfoot tr').html(
'<th>Attachment UId ' + rnd + '</th>' +
'<th>Attachment Name ' + rnd + '</th>' +
'<th>Attachment Type ' + rnd + '</th>' +
'<th>Created On ' + rnd + '</th>' +
'<th>Printout ' + rnd + '</th>'
);
$('#example').dataTable({
'aoColumnDefs': [{
"sClass": "hide_me",
"aTargets": [0]
}],
'destroy': true,
'data': response,
'columns': [
{
"title": "Attachment UId " + rnd,
"data": "AttachmentUid"
}, {
"title": "Attachment Name " + rnd,
"data": "AttachmentName"
}, {
"title": "Attachment Type " + rnd,
"data": "AttachmentType"
}, {
"title": "Created On " + rnd,
"data": "CreatedOn"
}, {
"title": "Printout " + rnd,
"data": "Printout"
}
]
});
}
<link href="http://datatables.net/release-datatables/media/css/jquery.dataTables.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="http://datatables.net/release-datatables/media/js/jquery.dataTables.js"></script>
<table id="example" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>AttachmentUid</th>
<th>AttachmentName</th>
<th>AttachmentType</th>
<th>CreatedOn</th>
<th>Printout</th>
</tr>
</thead>
<tfoot>
<tr>
<th>AttachmentUid</th>
<th>AttachmentName</th>
<th>AttachmentType</th>
<th>CreatedOn</th>
<th>Printout</th>
</tr>
</tfoot>
</table>