input field in data table

input field in data table

paalimopaalimo Posts: 1Questions: 0Answers: 0
edited April 2014 in General
Hi, I have a checkbox in each row of the table, but it send its value only in first page. In all other pagesthe checkbox is visibile but can't send its value.
Could you help me?

Thanks

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Hi,

    The issue here is that DataTables will remove elements that it does not require to display the current page from the document (i.e. all rows other than the displayed page). It does this both for performance and compatibility reasons, but it means that when you submit a form, the browser only sees the form elements on the current page.

    There are a number of ways to address this:

    1. If using Ajax - you can obtain all of the form information from the DataTable using its API like this: http://datatables.net/release-datatables/examples/api/form.html .

    2. If not using Ajax - one submit move all of the form elements into the form - you could do that like this:

    [code]
    $('#myForm').on( 'submit', function () {
    table.$('input').appendTo( '#myForm' );
    } );
    [/code]

    In that case, the fact that the DOM elements for the form are no longer in the table doesn't matter since the page will refresh anyway.

    Do you have an example page that you could link to so I can take a look?

    Thanks,
    Allan
This discussion has been closed.