in DataTable, Initialization of datatable with destroy true and then fnRowCallback to change row

in DataTable, Initialization of datatable with destroy true and then fnRowCallback to change row

anuruddhaanuruddha Posts: 2Questions: 1Answers: 0

in DataTable, Initialization of datatable with destroy true and then fnRowCallback to change row color or then appending rows to tbody. Why I am doing this is if I am appending rows first, and then initializing it get appended to same table or table comes with same data every time.

Below is my code########

success: function (msg) {
$.each(msg.d, function (index, obj) {
var i = 1 + index;
row += "<tr><td>" + i + "</td><td>" + obj.strank + "</td><td>" + obj.marks_diff + "</td><td>" + obj.mid + "</td><td>" + obj.fullname + "</td><td>" + obj.examid + "</td></tr>";

        });

        $('#dataTablesPre').DataTable({
            "responsive": true,
            "paging": false,
            "ordering": false,
            "info": false,
            "searching": true,
            "destroy": true,                
            "language": {
                "emptyTable": "",
                "zeroRecords":""
            },
            "fnRowCallback": function (nRow, aData, iDisplayIndex, iDisplayIndexFull) {
                if (aData[3] == "100000") {
                    $('td', nRow).css('background-color', 'Green');
                }
            }                
            });
         $("#dataTablesPre tbody").append(row);

    },
    error: function () { alert("Ajax Error"); }

In this code color change is not working, because I am destroy:true and appending data later , but how I can achieve it like-

Initilizing with destroy, then appending rows to tbody and then calling fnRowCallback to change row color, or any other way.

Please .

Thanks

Answers

This discussion has been closed.