Nov 13, 2020
0
Level 1
i am usin jquery datatable and i want to use createdrow in datatable but its now work
i am using jquery datatable in laravel project with using ajax and I want to make red those time fields that are for example > = '10: 10 ' if who can help me I'll be very grateful to you here my source code
$(document).ready(function() {
function load_data(from_date = '', to_date = '') {
$('#order_table').DataTable({
processing: true,
serverSide: true,
responsive: true,
ajax: {
url: '{{ route("daterange.index") }}',
data: {
from_date: from_date,
to_date: to_date
}
},
dom: "<'row'<'col-sm-12 col-md-4'l><'col-sm-12 col-md-4'B><'col-sm-12 col-md-4'f>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
"buttons": [
'excel', 'copy', 'print'
],
responsive: true,
"columns": [
{ "data": "name" },
{ "data": "operdate" },
{ "data": "dateout" },
{ "data": "datein" },
{ "data": "fdateout" },
{ "data": "fdatein" },
],
"createdRow":function(row,data,Index){
// if ( data[5].replace(/[$,:]/g, '') > 0810 ) {
if(data[5] >= '10:10'){
$('td', row).eq(5).addClass('highlight');
// $(row).addClass( 'colored-row' );
// $('td',row).css({
// 'background-color':'#FF0000',
// 'color':'white',
// 'border-style':'solid',
// 'border-color':'#bdbdbd'
// });
}
},
});
}
load_data();
});
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.22/css/jquery.dataTables.min.css">
<script src=" https://code.jquery.com/jquery-3.5.1.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/1.10.22/js/jquery.dataTables.min.js"></script>
Please or to participate in this conversation.