How to programmatically get first matched row after table.search("criteria").draw()

How to programmatically get first matched row after table.search("criteria").draw()

chaos037chaos037 Posts: 2Questions: 0Answers: 0

hi all,
currently im trying to create a custom code to programmatically search and get the matched row but what i got is not the first matched row instead i got is the first row that originally initialized.

For example, i got the current row of record and was initialized and displayed on the table

Row1 A
Row2 B
Row3 C

i used the following code to search for 'C' and get first matched row

table.search("C").draw(true);

console.log(table.row(0).data());

but instead of getting Row3 C ,i got Row1 A.

is there anyway i can get the matched row programmatically?
Appreciate for any help give and please forgive my poor english.

below is my setting for the datatable.

('#table').DataTable({
            "ajax": "getRecords.php",
            "pagingType": "full_numbers",
            "deferRender": true,
            "processing": true,
            "responsive": true,
            "dom": "<'row'<'col-sm-6'l><'col-sm-6'f>>" +
                    "<'row'<'col-sm-12'tr>>" +
                    "<'row'<'col-sm-3'i><'col-sm-7'p><'col-sm-2'<'pageNumberInput'>>>",
            "lengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]],
            "columns": [
                {"data": "Row", "width": "40%"},
                //some column...
            ]


        });

Replies

  • allanallan Posts: 62,998Questions: 1Answers: 10,371 Site admin

    You need to use the selector-options mentioned in the row() reference. Specifically table.row( 0, { page: 'current' } ) would do it.

    Allan

  • chaos037chaos037 Posts: 2Questions: 0Answers: 0

    thanks for your help.
    Awesome plugin! Keep up the good work.

This discussion has been closed.