Check box events
Check box events
vsek
Posts: 30Questions: 17Answers: 0
I am not able to get my "alert" to ever happen when clicking on or off the checkbox on column 0. Is there something I am doing wrong with code below:
$(document).ready(function() {
var dataTableId = '#standard_datatable';
// Data Table
var result;
var table = $(dataTableId).DataTable({
sortTableByCol : 1,
dom: 'Bfrtip',
select: true,
ajaxSource : "/cma/contents/screening/restrictedEntityGroupDetails_data?groupName=<%= (String)request.getAttribute("groupName")%>",
'columnDefs': [
{
'targets': 0,
'checkboxes': { 'selectRow': true},
'createdCell': function (td, cellData, rowData, row, col){
if(rowData[0] === '1')
{this.api().cell(td).checkboxes.select(); }
}
},
],
buttons: [
'copy', 'excel', 'pdf',
{
//Add new config button~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
text: 'Save selected Items' ,
action: function ( e, dt, node, config ) {
var rows_selected = table.rows({selected: true}).data();
//var rows_selected = table.column(0).checkboxes.selected();
$.each(rows_selected, function (index, rowId) {
result = $.ajax({
type: 'POST',
async: false,
url:"/cma/contents/screening/restrictedEntityGroupDetails_data_edit" ,
data: {'groupName' : "<%= (String)request.getAttribute("groupName")%>", 'row' : rowId[1] , 'checked' : rowId [0]},
context: this,
});
});
$('#standard_datatable').DataTable().ajax.reload();
}
}
],
"order": [[ 12, "desc" ]]
});
//hide the guid columns
table.column( 1).visible( false );
table.column( 11).visible( false );
table.column( 12).visible( false );
});
$("#standard_datatable").on('change',"input[type='checkbox']",function(e){
alert();
});
Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
This discussion has been closed.
Answers
Looks like you are using the Gyrocode checkboxes plugin. This uses the Select Extension. Take a look at these examples for how to use the Select API's and events.
Kevin