rowCallback() works with ajax call?

rowCallback() works with ajax call?

vulkyrievulkyrie Posts: 1Questions: 1Answers: 0

I want to highlight row based on condition.
If i put data in table manually rowcallback works, but when i try to get data from ajax call rowcallback does not work? Any solutions for this?

i tried row().data().each() but that is inconsistent

var table = $("#wo-dt").DataTable(
            {
                "ajax": 'operations.php?data=wodt'
            },
            {
                "rowCallback": function( row, data ) {
                    alert("Working");
                    // if ( data[4] == "A" ) {
                    // $('td:eq(4)', row).html( '<b>A</b>' );
                    // }
                }
            } 
        );

Answers

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

    Hi @vulkyrie ,

    You're incorrectly passing two objects into DataTables. It should be:

    var table = $("#wo-dt").DataTable(
                {
                    "ajax": 'operations.php?data=wodt'
                    "rowCallback": function( row, data ) {
                        alert("Working");
                        // if ( data[4] == "A" ) {
                        // $('td:eq(4)', row).html( '<b>A</b>' );
                        // }
                    }
                }
            );
    
This discussion has been closed.