jeudi 12 septembre 2019

Deleting all table row by checkbox

I am using checkbox for deleting rows separately and also using one checkbox(Select all) for checking all the checkboxes and deleting all rows.All the individual checkboxes are working correctly.But if i check the select all checkbox it only check the first page checkboxes and other page checkboxes are not checked.So help me how to check all the checkboxes for all the pages in pagination.

{

    <script type="text/javascript">

         $(document).ready(function () {
        $('#testtable').dataTable();
    });

   </script>



<script>  








    //SelectAll checkBox
    /****************************/
    $(document).ready(function(){ 

    $('#checkall').click(function(){
        if(this.checked)
        {
            $('.delete_checkbox').each(function(){
                this.checked=true;
                $(this).closest('tr').addClass('removeRow');
            });
        }
        else
        {
            $('.delete_checkbox').each(function(){
                this.checked=false;
                $(this).closest('tr').removeClass('removeRow');
            });
        }
    });
    /********************************/


    //Select indivisual checkBox
    /*******************************/
    $('.delete_checkbox').click(function(){

        if($(this).is(':checked'))
        {
            $(this).closest('tr').addClass('removeRow');
        }
        else
        {
            $(this).closest('tr').removeClass('removeRow');
        }
    });
    /*******************************/











});


</script>

}

I divided the data in multiple pages
when i select the checkbox it all select the rows of first page on the table.

"I ADD BELOW LINE BECAUSE STACKOVER FLOW GIVE ERROR MOSTLY CODE" " PLEASE DO NOT DOWN VOTE THIS IS MY FIRST QUESTION ON STACKOVERFLOW" " i want to select all the rows of all pages I am using checkbox for deleting rows separately and also using one checkbox(Select all) for checking all the checkboxes and deleting all rows.All the individual checkboxes are working correctly.But if i check the select all checkbox it only check the first page checkboxes and other page checkboxes are not checked.So help me how to check all the checkboxes for all the pages in pagination."




Aucun commentaire:

Enregistrer un commentaire