Get checked checkboxes count number

Get checked checkboxes count number

satriyoachmadsatriyoachmad Posts: 2Questions: 1Answers: 0

Hi, i'm trying to get how many checked checkboxes when user do check the checkboxes on the table. i am using gyrocode checkboxes extension on datatables editor.
here are my codes

var datatable = $('#tempdat1Table').DataTable({
                processing: true,
                serverSide: true,
                scrollX: true,
                scrollCollapse: true,
                pageLength: 50,
                fixedHeader: {
                    header: true,
                    headerOffset: 47
                "fnInitComplete": function(){
                    $('.dataTables_scrollHead').css('overflow', 'auto');
                    $('.dataTables_scrollHead').on('scroll', function () {
                ajax: {
                    url: "{{ route('dashboard.client.p') }}",
                fixedColumns: {
                    leftColumns: 4,
                    rightColumns: 1
                order: [[1, 'desc']],
                columns: [
                        targets: 0,
                        data: 'id_tempdat',
                        defaultContent: '',
                        checkboxes: {
                            selectRow: false,
                        className: 'data-terpilih'
                        data: 'id',
                        name: 'id',
                        visible: false
                        data: 'id_tempdat',
                        name: 'id_tempdat',
                        width: '5%'

and this is the way i tried to count the checkboxes

$("#tempdat1Table").on("click", "input.dt-checkboxes", function (event) { 
                count_number= datatable.column(0).checkboxes.selected();

it didn't do any result.
if i change the action to "on click anywhere" like below

                count_number = datatable.column(0).checkboxes.selected();

the result successfully show up except when i click on checkboxes.

how can i get the result when user exactly check the checkboxes ?

This question has an accepted answers - jump to answer


Sign In or Register to comment.