Sending all the pages with fields in the rows [My simple solution]

Sending all the pages with fields in the rows [My simple solution]

ProfeRonaldProfeRonald Posts: 2Questions: 0Answers: 0

This is my simple solution

// MUST CHANGE BUTTON TYPE FROM "submit" TO "button"

$(document).ready(function() {
    $(document).on('click', '#IdButtonSubmit', function () {
    //$("#YourIdDataTable").css({display:'none'});  // if you don't want to show all the pages //
    $("select[name=YourIdDataTable_length]").val("-1"); // change the selected value to "All"
    $("select[name=YourIdDataTable_length]").change(); // Datatable detects the change
    $('#IdButtonSubmit').focus(); // focus submit button
    $("#IdForm").submit(); // submit the form


});
});

You need to add options to avoid resize the page.

Replies

  • rf1234rf1234 Posts: 2,801Questions: 85Answers: 406

    cool! thanks for sharing!

  • ProfeRonaldProfeRonald Posts: 2Questions: 0Answers: 0

    if you want to prevent the page resizing. Add another div on top of your
    "DivTableContainer":

    1-

         <div class="DivTableContainer">
        <table ....
        </table>
    

    2 -
    var noresize = $('#YourIdDataTable').parents('.dataTables_wrapper').clone(true, true);
    noresize.appendTo('#cloneTable');
    $("#IdButtonSubmit").prop('disabled', true);

    Full Code:
    // MUST CHANGE BUTTON TYPE FROM "submit" TO "button"

        $(document).ready(function() {
            $(document).on('click', '#IdButtonSubmit', function () {
            var noresize = $('#YourIdDataTable').parents('.dataTables_wrapper').clone(true, true); // Clone table for prevent the page resizing       
            $("#YourIdDataTable").css({display:'none'});  // Avoid show all the pages. //
            $("#DivTableContainer").css("width", "0px");  // to hide the "DivTableContainer"
              $("#DivTableContainer").css("height", "0px"); // to hide the "DivTableContainer"
            $("select[name=YourIdDataTable_length]").val("-1"); // change the selected value to "All"
            $("select[name=YourIdDataTable_length]").change(); // Datatable detects the change
            //$('#IdButtonSubmit').focus(); // focus submit button 
                noresize.appendTo('#cloneTable'); // Write the current page of the table.
            $("#IdButtonSubmit").prop('disabled', true); // Prevents cloning more times.
            $("#IdForm").submit(); // submit the form
        });
        });
    
This discussion has been closed.