Why my createdRow not work ? who can help me ?

Why my createdRow not work ? who can help me ?

sulaysulay Posts: 1Questions: 1Answers: 0

//
$(document).ready(function() {

// var t =
$('.input-daterange').datepicker({
todayBtn: 'linked',
format: 'yyyy-mm-dd',
autoclose: true

});





load_data();

function load_data(from_date = '', to_date = '') {
       $('#order_table').DataTable({
        "createdRow":function(row,data,index){
   // if ( data[5].replace(/[\$,:]/g, '')  > 0810 ) {
    if(data[5] >= 10){
         $('td', row).css('background-color', '#FF0000 !important');
         $('td', row).css('color', 'green');
         $('td', row).eq(0).css({ 'color': 'white' }) //Added specific cell CSS
               }
        // $('td', row).css({
        //            'background-color':'#FF0000',
        //            'color':'white',
        //            'border-style':'solid',
        //            'border-color':'#bdbdbd'
        //        });
        //    }
       },
        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: 'id',
            //     name: 'id'
            // },
            {
                data: 'name',
                name: 'name'
            },
            {
                data: 'operdate',
                name: 'operdate'
            },
            {
                data: 'dateout',
                name: 'dateout'
            },
            {
                data: 'datein',
                name: 'datein'
            },
            {
                data: 'fdateout',
                name: 'fdateout'
            },
            {
                data: 'fdatein',
                name: 'fdatein'
            },
            {
                data: 'place',
                name: 'place'
            },
            {
                data: 'manager',
                name: 'manager'
            },
            {
                data: 'comment',
                name: 'comment'
            },


        ],

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    The reason this went into the spam filter is because it was just code, which makes it look like an attack. It would help if you say why it doesn't work, rather than "it just doesn't work". Also, as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

This discussion has been closed.