In the project to be used in the bulk delete, delete the need to check box, now posted code for later use.
The HTML code is as follows
<Buttonclass= "btn btn-xs btn-danger"onclick= "Delbatchinfo (' Patroltask ')"><Iclass= "Ace-icon fa fa-trash-o bigger-120"></I>Delete check box</Button><TableID= "DataTable"class= "Table table-striped table-bordered table-hover"> <thead><TR><thclass= "Center"><label><inputtype= "checkbox"class= "Ace"name= "Delbatch"/><spanclass= "LBL"></span></label></th><thclass= "Center">Number</th></TR> </thead> <tbody><TR><thclass= "Center"><label><inputtype= "checkbox"class= "Ace"name= "Delbatch" name= "Delbatch" value= "' +data.data[item].id+ '"/><spanclass= "LBL"></span></label></th><TDclass= "Center"></TD></TR></tbody></Table>
Js
function () { varthis; $ (this). Closest (' table '). "Find (' tr > Td:first-child input:checkbox ') . each ( function() { this. Checked= that.checked; $ (this). Closest (' tr '). Toggleclass (' selected ');});
Delbatchinfo method
/********************************************** function Name: delbatchinfo function: Delete records in bulk milan******************************** ****************/functionDelbatchinfo (type) {varDelmesshtml= ""; varcheckednum=$ ("Input[name= ' Delbatch ']:checked"). length; if(Checkednum = = 0) {alert ("Please select Delete Object!" "); return; } if(Confirm ("Warning: Do you want to completely delete records?") ")){varcheckedlist=NewArray (); $("#datatable"). Find (' tr > Td:first-child input:checkbox '). each (function() {Checkedlist.push ($ ( This). Val ()); }); } ... }
When I pass a value in the delete prompt, the deletion error, the error code is as follows:
if (Confirm ("Warning: Do you want to completely delete records?") ")) { var checkedlist=New Array (); $ ("input[name= ' Delbatch ']:checked"). each (function() { Checkedlist.push ($ ( ). Val ()); });
Reason is
$ ("Input[name= ' Delbatch ']:checked"). each (function() {
This code iterates through all the checkboxes, including the check boxes that are always checked. The total check box does not have an ID value.
The correct code should:
$ ("#datatable"). Find (' tr > Td:first-child input:checkbox ')
This is the only option to select the TD check box in TR
After each deletion, after the setlisttable (nowpage) Refresh page, the total check box still handles the tick state,
Only the contents of Table>thead can be put into the Setlisttable method to solve
var tablehmtl= '<thead><TR><thclass= "Center"><label><inputtype= "checkbox"class= "Ace"name= "Delbatch"ID= "Checkall"/><spanclass= "LBL"></span></label></th><thclass= "Center">Number</th></TR> </thead> <tbody>'; tablehmtl+= '<TR><TDclass= "Center"><label><inputtype= "checkbox"class= "Ace"name= "Delbatch"value= "' +data.data[item].id+ '"/><spanclass= "LBL"></span></label></TD><TDclass= "Center">' +data.data[item].id+ '</TD><TR>'; tablehmtl+= '</tbody>'; $ ("#datatable"). HTML (TABLEHMTL);
Bulk Delete-check box