Get checked checkboxes count number
Get checked checkboxes count number
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 () {
$('.dataTables_scrollBody').scrollLeft($(this).scrollLeft());
});
},
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();
alert(count_number.length);
});
it didn't do any result.
if i change the action to "on click anywhere" like below
$(document).click(function(event){
count_number = datatable.column(0).checkboxes.selected();
alert(count_number.length);
});
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
Answers
I Opened the console at the Gyrocode checkbox plugin example and entered this:
The click event does work.
If you need help troubleshooting your click event then please provide a link to your page or a test case replicating the issue.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Also note that the Gyrocode checkbox plugin is a third party plugin. For plugin support contact the developer.
Kevin
oh i got it, i forgot to put style multi and selectRow true.
and