我遇到了一个问题,我需要复选框来删除多个候选项而不是单独删除它们。我正在使用codeigniter和datatables(jQuery)
<?php echo $this->table->generate(); ?>
这就是它在视图中加载的方式。下面我将放置我的控制器:
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();
}
任何帮助都将不胜感激,谢谢。
答案 0 :(得分:0)
如果您只是想知道如何显示复选框,则jQuery数据表内置了此功能。您需要添加:
<property>
<property-name>session-timeout</property-name>
<property-value>86400</property-value>
</property>
...
<property>…</property>
您可以在jsfiddle http://jsfiddle.net/gyrocode/abhbs4x8/
上查看此示例答案 1 :(得分:0)
使用输入名称中的方括号。
<input name="candidates[]" value="1" type="checkbox">
<input name="candidates[]" value="2" type="checkbox">
...