Cannot select row on another page

Cannot select row on another page

jdoensjdoens Posts: 11Questions: 2Answers: 0
edited November 14 in Free community support

Hi everyone,

I'm trying to select the row where I get a positive match but can't seem to gain focus of the row that I match. Below is my code
...
var dtable = $('#datatable').dataTable().api();

        dtable.rows().eq(0).each(function (index) {
            var row = dtable.row(index);
            var data = row.data();

            if (data.Name == 'John') {
                this.addClass("selected");
            }
        ...

I've also tried $(this).closest('tr').addClass('selected') and other variations but haven't had any luck. Any pointers would be greatly appreciated!

Answers

  • jdoensjdoens Posts: 11Questions: 2Answers: 0

    I answered my own question. I simply invoked the select() method by row.select().

  • jdoensjdoens Posts: 11Questions: 2Answers: 0

    So it works if the data is found on the first page, but the select doesn't happen if the data is on another page within the DataTable. Is this something I'm doing wrong?

  • jdoensjdoens Posts: 11Questions: 2Answers: 0

    row.show().draw(false) worked.

  • allanallan Posts: 43,187Questions: 1Answers: 5,628 Site admin

    There isn't a row.show() method in DataTables - I'm not entirely sure how that is working unless you have a plug-in method? Perhaps you can link to a page showing the issue?

    Allan

Sign In or Register to comment.