php - Codeigniter:如何使用 jQuery 添加带有复选框的列以进行多项选择和删除

标签 php jquery codeigniter datatables

我遇到一个问题,我需要复选框来删除多个候选人而不是单独删除他们。我正在使用 codeigniter 和数据表(jQuery)

    <?php echo $this->table->generate(); ?>

这就是它在 View 中加载的方式。下面我将放置我的 Controller :

    public function index ()
    {
        // Fetch all users
        // $this->data['tasks'] = $this->task_m->get();
        //datatable
        $tmpl = array ( 'table_open'  => '<table id="big_table" border="1" cellpadding="2" cellspacing="1" class="table ">' );
        $this->table->set_template($tmpl); 
        $this->table->set_heading('Select','Client Name','Subject','Booking Date','Status','Actions');

        // Load view
        $this->data['subview'] = 'admin/task/index';
        $this->load->view('admin/_layout_main', $this->data);
    }

下面是我的模型:

    public function list_tasks(){
    $userID = $this->session->userdata('id');

   $this->datatables->select("ci_customer.firstname,ci_task.subject_desc, ( DATE_FORMAT ( ci_task.booking_date ,('%d/%m/%Y
    '))), IFNULL( ( select c.pinged_status from ci_task_revisions c where c.task_id = ci_task.task_id order by revision_id desc limit 1 ), (ci_task.status) ) as status, ci_task.task_id,(CASE WHEN Date(ci_task.due_date) < CURDATE() AND ci_task.status <>'COMPLETE' THEN 'overdue' WHEN ci_task.assigner_id=ci_task.assignee_id THEN 'self' WHEN ci_task.assigner_id =$userID THEN 'assignee'  WHEN ci_task.assignee_id =$userID THEN 'assigner'  ELSE 'default'  END ) as type, ci_task.read")
    ->join('ci_customer','ci_customer.customer_id = ci_task.customer_id');


    $where = 'ci_task.assigner_id ='.$userID.' OR ci_task.assignee_id ='.$userID.'';
    $this->datatables->where($where);

    $this->datatables->edit_column('ci_task.task_id', btn_edit('admin/task/edit/' . '$1').' '.btn_sms('admin/task/sendSMS/' . '$1').' '.($this->session->userdata('role')?btn_delete('admin/task/delete/' .  '$1'):'')  ,'ci_task.task_id')
    ->from($this->_table_name);
    return $this->datatables->generate();
}

如有任何帮助,我们将不胜感激。

最佳答案

如果您只是想知道如何显示复选框,则 jQuery 数据表内置了此功能。您将需要添加:

<input name="select_all" value="1" type="checkbox">

您可以在 jsfiddle http://jsfiddle.net/gyrocode/abhbs4x8/ 上查看此示例

关于php - Codeigniter:如何使用 jQuery 添加带有复选框的列以进行多项选择和删除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33956112/

相关文章:

php - 投票系统每次加减1-5

javascript - 使用Node.JS查询MySQL并在网页中显示结果

javascript - 使用 jquery 添加/删除 ul 列表的事件类?

php - 我可以在mysql中使用if语句吗?

php - 根据ID提取图片

php - mysqli_fetch_assoc()需要参数/调用成员函数bind_param()错误。如何获取并修复实际的mysql错误?

php - 如何保护项目中的数据库配置文件?

Jquery draggable 没有到达容器的边缘

javascript - CodeIgniter REST_Controller 初学者问题

php - Codeigniter Active Record IF 语句