Hi All,
I am working MVC web application in data display on the grid and downloading excel on the report.
I need format column like hh:mm:ss user need sum the column below code i am using below code but it’s not working
please suggest
$.ajax({
type: "POST",
dataType: "json",
data: filterobj,
url: baseUrl + "TransactionLog/GetTransactionLogWithFilter",
beforeSend: function () {
$('.overlay').show();
},
success: function (result) {
var finaldata = result;
if (finaldata != null && finaldata.length > 0) $(".btn-download").show();
else $(".btn-download").hide();
if ($.fn.DataTable.isDataTable('#transactionlogtable')) { $('#transactionlogtable').DataTable().destroy(); }
transactionlogtable = $("#transactionlogtable").DataTable({
"oLanguage": {
"sEmptyTable": "Data not available for the selected filter combination"
},
"data": finaldata,
"bLengthChange": false,
"oSearch": { "bSmart": false },
"order": [[6, "desc"]],
"columns": [
{ "data": "standingActualFileName" },
{ "data": "standingFileSize" },
{ "data": "standingFilePages" },
{
"data": "transactionStandingFile",
"render": function (data, type, full, meta) {
if (data) {
return "<a href='javascript:void()' title='" + data.standingActualFileName + "'>" + data.standingActualFileName + "</a><p class='m-0'>File Size - " + data.standingFileSize + " KB <span class='mr-1 ml-1'>|</span> <span>Page count - " + data.standingFilePages + "</span></p>"
}
}
},
{ "data": "fileType" },
{ "data": "uploadedByUserName" },
{ "data": "uploadedTimeDisplay" },
{ "data": "timeTaken" },
{
"data": "status",
"render": function (data, type, full, meta) {
if (data == "2") {
return "<span class='badge badge-success'>Completed</span>"
}
else {
return "<span class='badge badge-danger'>Failed</span>"
}
}
},
{ "data": "uploadTime" },
{ "data": "id" }
],
"columnDefs": [
{ "orderData": [9], "targets": [6] },
{ "visible": false, "targets": [0, 1, 2,9,10] }
],
dom: 'Blfrtip',
buttons: [{
extend: 'excelHtml5',
customize: function (xlsx) {
var sheet = xlsx.xl.worksheets['sheet1.xml'];
$('row c', sheet).attr('s', '25');
$('row:first c', sheet).attr('s', '47');
var nFmt = '<numFmt numFmtId="777" formatCode="[hh]:mm:ss"/>';
// Loop over the cells in column `J`
$('row c[r^="H"]', sheet).each(function (key, value) {
// Get the value
if (key != 0 && $('is t', this).text() == 'Failed') {
$(this).attr('s', '11');
}
});
$('row c[r^="G"]', sheet).each(function (key, value) {
// Get the value
$(this).attr('s', '777');
});
},
sheetName: 'TransactionLog',
filename: "Transaction Log",
header: true,
title: '',
//customize: function (xlsx) { },
exportOptions: {
columns: ':not(.notexport)',
format: {
body: function (data, row, column, node) {
var Val = data.toString();
if (Val.startsWith("=") || Val.startsWith("+") || Val.startsWith("-") || Val.startsWith("@")) {
return "\u200C" + node.innerText;
}
else
return node.innerText;
}
}
}
}]
});