user1281991
user1281991

Reputation: 773

Datatables select only filtered content

In this example

Try search for "airi" - only one result will show.

Try Submit the form, you can easily see the next row (actually the enrire table) gets submitted also.

How can I do so it is only the filtered rows that gets submitted?

Best regards

Upvotes: 0

Views: 828

Answers (1)

Adriien M
Adriien M

Reputation: 1185

You can add the :visible selector:

$(document).ready(function() {
    var table = $('#example').DataTable();

    $('button').click( function() {
        var data = table.$('input:visible, select:visible').serialize();
        alert(
            "The following data would have been submitted to the server: \n\n"+
            data.substr( 0, 120 )+'...'
        );
        return false;
    } );
} );

Upvotes: 1

Related Questions