Bulk Delete

Bulk Delete - Select multiple records and delete. You cannot delete the record with a key : EBGC57SXM-VW47I6AF-401X7DYM.


public function bulk_delete()
{
  $xcrud = get_xcrud();
  $xcrud->table('million');
  $xcrud->limit_list('20,50,100,1000'); // do not use 'all' for large tables
  $xcrud->bulk_select_position('left'); //It can be 'left' or 'right'
  //$xcrud->set_bulk_select(false);
  $xcrud->set_bulk_select(false,'cd_key','=','EBGC57SXM-VW47I6AF-401X7DYM');//Dont be able to select records with ID 287846
  $xcrud->unset_remove(true,'cd_key','=','EBGC57SXM-VW47I6AF-401X7DYM');
  $xcrud->create_action('bulk_delete', 'bulk_delete'); // action callback, function publish_action() in functions.php
  echo $xcrud->render();
  
  $data['content'] = $xcrud->render();
  
  //this line loads the <button> and <script> below it from a view
  $data['script'] = view('scripts', ['code' => 'bulk_delete']);
  
  <button class="btn btn-primary" onclick="deleteItems();">Delete Selected</button>
  
  <script>
  function deleteItems(){
    var r = confirm("Confirm deletion of " + items.length + " items.");
    if (r == true) {
    Xcrud.request('.xcrud-ajax',Xcrud.list_data('.xcrud-ajax',{action: 'bulk_delete',   task:'action',selected:items,table:'million',identifier:'id'}))
      items = [];
    }       
  }
  </script>
    
  
  return view('demos', $data);
}

Million

#User IdCd KeySumActivated 
1444147qwww1.26No
2444147R03QHWV5A-6ZWGKJLJ5-5KD3GSSDL1.26No
3444147R9P7ZC7BI-72DZI1Q01-5MCB019BL1.26No
4444147S9O6N9ZF2-7BPJTDUU9-5TR7QNYFL1.26No
5444147SR7TN1X8U-7G986JCDD-5XDEK0LZL1.26No
6444147UGJK0JOSU-7W5BG3ULD-6A0G4LYZL1.26No
7444147USRQHFV66-7ZBDQZUQP-6CJ6ATGNL1.26No
8444147UWPHPLL5A-80C45FZJ5-6DCE57NVL1.26No
9444147V1H69MH74-81KLPZ00F-6EBS1HL7X1.26No
10444147V6W98KUKU-82Z5L4PPD-6FFZKK0ZL1.26No
Search