How to dynamically read no. of selected rows in jquery data table

How to dynamically read no. of selected rows in jquery data table

BiswajitroxBiswajitrox Posts: 2Questions: 2Answers: 0

How to dynamically read no. of selected rows in jquery data table .e.g- when a table appear on a screen with some check-box selected for each row (after some click event) ,then it should display below that 5 row selected to add.
http://ctrlv.in/608821 like this example here

This question has an accepted answers - jump to answer

Answers

  • neurofunkneurofunk Posts: 14Questions: 5Answers: 1
    edited July 2015 Answer ✓

    example column with checkboxes:

    "columns" : [
                {
                    "data" : row[0],
                    "render" : function(data , type , row){
                        return '<input class="ch" type="checkbox" value='+data+' />'
                    }
    
                }
    ],
    

    and script which counts selected checkboxes

    $(document).ready(function (){ 
        $('body').on('change' , '.ch' , function(){
            var checked = 0
            $('.ch:checked').each(function (){
                checked = checked +1
                console.log(checked)
    
                      $('.info').text(checked + " rows are selected")
    
            })
        })
    })
    
This discussion has been closed.