Tonmoy Saha

Tonmoy Saha

  • NA
  • 37
  • 785

Dynamically bind Id to a Datatable column

Sep 1 2017 5:47 PM
$.ajax({
type: "POST",
url: path,
dataType: "json",
data: { ClientCode: clientCode },
success: function (result) {
var table = $('#finalizeTable').DataTable({
'columnDefs': [
{
'targets': 5,
'createdCell': function (td, cellData, rowData, row, col) {
$(td).attr('data-toggle', 'popover');
$(td).attr('data-trigger', 'hover');
$(td).attr('id', 'OrderId');
}
}
]
});
table.clear().draw();
for (var i = 0; i < result.length; i++) {
var OrderId = result[i].OrderId;
var remove = '';
var details = 'view Details';
var rowNode = table.row.add([
result[i].OrderId,
result[i].OrderNo,
result[i].ShopName,
result[i].OrderDate,
result[i].Total,
details,
remove,
]);
table.column(0).visible(false);
//table.column(5).addClass(selectdetails);
//table.column(5).attr('id', result[i].OrderId);
var theNode = $('#finalizeTable').dataTable().fnSettings().aoData[rowNode[0]].nTr;
theNode.setAttribute('id', +result[i].OrderId);
}
table.draw();
 
Can Anyone help me how can i bind orderid to column 5 dynamically for each row. 
 
 

Answers (1)