0

I try to hide buttons in my table when certain value is not "error".

It works perfectly fine on the first page, but due to pagination the buttons are not hidden on the second page.

JSFiddle

$(function() {
$('#table1').each(function() {
var Cell = $(this).find('td:eq(2)');
debugger;
if (Cell.text() !== 'error' ) {
$(this).find('button').hide();
       }
    });
});

2 Answers 2

1

Like you have done with the initComplete callback, you can pass a drawCallback function through the DataTable options. This will run everytime the table is drawn. Just add the following to the options.

JSFiddle

See: https://datatables.net/reference/option/drawCallback

drawCallback: function (settings) {
    $('#table1').each(function () {
        var Cell = $(this).find('td:eq(2)');
        debugger;
        if (Cell.text() !== 'error') {
            $(this).find('button').hide();
        }
    });
}
Sign up to request clarification or add additional context in comments.

Comments

0

You have to call the function when the page change. If you inspect the table you can see all rows not been loaded.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.