How to Iterate through the table on Sort Serverside?

How to Iterate through the table on Sort Serverside?

SAKIFSAKIF Posts: 8Questions: 3Answers: 0

So I am Iterating through the table on initialization completion to find a value and when i do i add a class to the row. The issue is when sorted it doesn't go thought that function. i was wondering if there is a declaration like "initComplete" for sort .

"initComplete": function () {

            //***********************************************************************************
            // move column filters to the top instead of being at the bottom
            var r = $('#tblPayroll tfoot tr');
            // if you are using bootstrap, set the correct padding
            r.find('th').each(function () {
                $(this).css('padding', 8);
            });
            $("tr").each(function () {
                var col_val = $(this).find("td:eq(0)").text();
                if (col_val == "999") {
                    $(this).addClass('datatotal');  //the selected class colors the row green//
                }
            });
            $('#tblPayroll thead').append(r);
        }

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,368Questions: 26Answers: 4,956
    Answer ✓

    You probably will want to use rowCallback instead of initComplete. rowCallback will iterate through each row it displays so all yo need is to perform your check of that row.

    Kevin

  • SAKIFSAKIF Posts: 8Questions: 3Answers: 0
    edited April 2018

    Thanks @kthorngren I used the createdrow option.

    //***********************************************************************************
    "createdRow": function (row, data, index) {
    var a = data.a;
    var b = data.b;
    if (data.a > 10 || data.a < -10)
    {
    $(row).addClass('exceptions');
    }
    if (data.b == "999") {
    $(row).addClass('datatotal'); //the selected class colors the row green//
    }
    }

This discussion has been closed.