Это мой контроллер:
Код: Выделить всё
public function show_all_issues()
{
$project_model = new Project_Model();
$arr_project = $project_model->get_selected_project()->getResult();
$project_id = '';
foreach ($arr_project as $data) {
$project_id = $data->id;
}
$model = new Issue_Model();
$lists = $model->get_all_issues($project_id);
$data = [];
$no = $_POST["start"];
foreach ($lists as $list) {
$color = '';
$no++;
$row = [];
$row[] = '';
$row[] = $no;
$row[] = $list->issue_key;
$row[] = $list->issue_title;
$row[] = $list->issue_reporter;
$row[] = $list->issue_assignee;
if ($list->issue_label == 'Open') {
$color = 'secondary';
} else if ($list->issue_label == "Waiting for Support") {
$color = 'info';
} else if ($list->issue_label == "Work In Progress") {
$color = 'warning';
} else {
$color = 'success';
}
$row[] = "$list->issue_label";
$row[] = $list->issue_created;
$data[] = $row;
}
$output = array(
"draw" => $_POST['draw'],
"recordsTotal" => $model->count_all(),
"recordsFiltered" => $model->count_filtered_all(),
'data' => $data
);
return $this->respond($output, 200);
}
Код: Выделить всё
protected $table = 'issues';
protected $column_order = array('issue_key', 'issue_reporter', 'issue_assignee', 'issue_label', 'issue_created');
protected $column_search = array('issue_key', 'issue_title', 'issue_reporter', 'issue_assignee', 'issue_label');
protected $order = array('issue_label' => 'desc');
protected $db;
protected $dt;
function __construct()
{
parent::__construct();
$this->db = db_connect();
$this->dt = $this->db->table($this->table);
}
private function _get_datatables_query()
{
$i = 0;
foreach ($this->column_search as $item) {
if ($_POST['search']['value']) {
if ($i === 0) {
$this->dt->groupStart();
$this->dt->like($item, $_POST['search']['value']);
} else {
$this->dt->orLike($item, $_POST['search']['value']);
}
if (count($this->column_search) - 1 == $i)
$this->dt->groupEnd();
}
$i++;
}
if ($_POST['order']) {
$this->dt->orderBy($this->column_order[$_POST['order']['0']['column']], $_POST['order']['0']['dir']);
} else if (isset($this->order)) {
$order = $this->order;
$this->dt->orderBy(key($order), $order[key($order)]);
}
}
function get_all_issues($project_id)
{
$this->_get_datatables_query();
if ($_POST['length'] != -1){
$this->dt->limit($_POST['length'], $_POST['start']);
}
$query = $this->dt->orderBy('issue_created', 'desc')->getWhere(['project_id' => $project_id]);
return $query->getResult();
}
function count_filtered_all()
{
$this->_get_datatables_query();
return $this->dt->countAllResults();
}
public function count_all()
{
$tbl_storage = $this->db->table($this->table);
return $tbl_storage->countAllResults();
}
Код: Выделить всё
No.
Key
Summary
Reporter
Assignee
Status
Created
$(document).ready(function() {
var table = $('#table').DataTable({
"processing": true,
"serverSide": true,
"ajax": {
"url": "/show_",
"type": "POST"
},
//optional
"lengthMenu": [
[5, 10, 25],
[5, 10, 25]
],
"columnDefs": [{
"targets": 0,
"orderable": false,
"checkboxes": {
"selectRow": true
},
"className": 'select-checkbox'
},
{
"targets": 3,
"orderable": false
}
],
"select": {
"style": 'multi',
"selector": 'td:first-child'
},
"order": [],
});
table.on("click", "th.select-checkbox", function() {
if ($("th.select-checkbox").hasClass("selected")) {
table.rows().deselect();
$("th.select-checkbox").removeClass("selected");
} else {
table.rows().select();
$("th.select-checkbox").addClass("selected");
}
}).on("select deselect", function() {
("Some selection or deselection going on")
if (table.rows({
selected: true
}).count() !== table.rows().count()) {
$("th.select-checkbox").removeClass("selected");
} else {
$("th.select-checkbox").addClass("selected");
}
});
});
Просмотр таблицы
Вот как выглядит ошибка:
Просмотр ошибок
Это происходит, когда я пытаюсь отсортировать столбцы исполнителя, столбец статуса и столбец созданного, но если я попытаюсь отсортировать остальные столбцы, ошибка не появится.
И еще один.. Если Я указываю false для значения ServerSide или делаю это как комментарий, ошибка не отображается.
Это так странно:]
Я понятия не имею, что не так с моим кодом. Кто-нибудь может помочь моему маленькому мозгу? Пожалуйста... :')
Подробнее здесь: https://stackoverflow.com/questions/631 ... mented-the
Мобильная версия