how to change color of cell
how to change color of cell
faruk
Posts: 4Questions: 2Answers: 0
if different **Plaka **and **DuzeltilmemisPlaka **I want to change background color when I export
could you help please
table = $('#table_id').DataTable({
//Dom Gösterim şeklşi B-> buttonlar l-> lengthMenu f-> filtre vs.
dom: "Blfrtip",
lengthMenu: [[10, 15, 25, 50, -1], [10, 15, 25, 50, "Hepsi"]],
//Dil
language: {
select: {
rows: "%d satır seçildi."
},
url: "http://cdn.datatables.net/plug-ins/1.10.12/i18n/Turkish.json"
},
//api url
ajax: {
url: apiUrl + url,
data: data,
dataSrc: ""
},
//kolon bazlı arama
initComplete: function() {
table.columns().every(function() {
var that = this;
$('input', this.footer()).on('keyup change', function() {
that.search(this.value).draw();
});
});
},
createdRow: function(row, data, index) {
if (data.Plaka !== data.DuzeltilmemisPlaka) {
var td2 = $('td', row).eq(2);
var td3 = $('td', row).eq(3);
td2.addClass('my_class');
td3.addClass('my_class');
}
},
//Colonlar
columns: [
{
data: "Yon",
render: function(data, type, full, meta) {
if (data == "G") {
return 'Giriş';
} else {
return 'Çıkış';
}
}
},
{ data: "KameraAd" }, //kamera adı
{
data: 'Plaka', render: function (data, type, full,row)
{
if (type == 'export') {
if (full.Plaka !== full.DuzeltilmemisPlaka) {
var td2 = $('td', row).eq(2);
var td3 = $('td', row).eq(3);
td2.addClass('my_class');
td3.addClass('my_class');
}
}
return data;
}
},
{ data: "DuzeltilmemisPlaka" },
{ data: "AracTip" }, //abonetip
{
data: "Zaman",
width: "20%"
},
{
data: "ResimDosyasi",
width: "11%",
orderable: false,
searchable: false,
render: function(data, type, full, meta) {
return '<a onclick=showImage("' + data + '")>Resim Göster</a>';
}
},
{
data: "ResimDosyasi",
orderable: false,
searchable: false,
render: function (data, type, full, meta) {
return '<a><img src="http://localhost:2003' + data + '" onclick=showImage("' + data + '") width="150" height="50"></a>';
}
}
],
// true ise row seçilebilir olur
select: true,
buttons: [
{
extend: "print",
text: "Yazdır",
exportOptions: { orthogonal: 'export', columns: ':visible' },
customize: function(win) {
$(win.document.body)
.css('font-size', '10pt')
.prepend(
'<img src="http://datatables.net/media/images/logo-fade.png" style="position:absolute; top:0; left:0;" />'
);
},
className: "btnozel"
},
{
extend: 'excelHtml5',
//customize: function(xlsx) {
// var sheet = xlsx.xl.worksheets['sheet1.xml'];
// // Loop over the cells in column `F`
// $('row c[r^="F"]', sheet).each( function () {
// // Get the value and strip the non numeric characters
// if ( $('is t', this).text().replace(/[^\d]/g, '') * 1 >= 500000 ) {
// $(this).attr( 's', '20' );
// }
// });
//},
exportOptions: { orthogonal: 'export' },
text: "Excel",
className: "btnozel"
},
{
extend: 'pdfHtml5',
exportOptions: { orthogonal: 'export' }, text: "PDF",
className: "btnozel"
},
{
extend: "colvis",
className: "btnozel",
text: "Gizle/Göster"
}
],
columnDefs: [
{
targets: -1,
visible: false
}
],
responsive: !0,
order: [[0, 'asc']],
});
This discussion has been closed.
Answers
any answer !! GREAT