Searching column doesn't work
Searching column doesn't work
Hello,
iam just tried to using datatable to show my data, all feature is fine (add,edit delete and sorting) except searching feature.
when i see XHR on chrome it show an error " Fatal error: Call to undefined method CI_DB_mysql_driver::group_start() in C:\xampp\htdocs\admin\application\modules\adminpage\models\adminpage_md.php on line 100 "
here's the code on my model :
! private function _get_datatables_query()
$this->db->from($this->table);
$i = 0;
foreach ($this->column_search as $item) // loop column
{
if($_POST['search']['value']) // if datatable send POST for search
{
if($i===0) // first loop
{
$this->db->group_start(); // open bracket. query Where with OR clause better with bracket. because maybe can combine with other WHERE with AND.
$this->db->like($item, $_POST['search']['value']);
}
else
{
$this->db->or_like($item, $_POST['search']['value']);
}
if(count($this->column_search) - 1 == $i) //last loop
$this->db->group_end(); //close bracket
}
$i++;
}
if(isset($_POST['order'])) // here order processing
{
$this->db->order_by($this->column_order[$_POST['order']['0']['column']], $_POST['order']['0']['dir']);
}
else if(isset($this->order))
{
$order = $this->order;
$this->db->order_by(key($order), $order[key($order)]);
}
}
on XHR tell that error in line : $this->db->group_start();
and here's the code on my view
!
$(document).ready(function() {
//datatables
table = $('#table').DataTable({
"responsive": true,
"processing": true, //Feature control the processing indicator.
"serverSide": true, //Feature control DataTables' server-side processing mode.
"order": [], //Initial no order.
// Load data for the table's content from an Ajax source
"ajax": {
"url": "<?php echo site_url('adminpage/ajax_list')?>",
"type": "POST"
},
"searchable":false,
//Set column definition initialisation properties.
"columnDefs": [
{
"targets": [ -1 ], //last column
"orderable": false, //set not orderable
},
],
});
//datepicker
$('.datepicker').datepicker({
autoclose: true,
format: "yyyy-mm-dd",
todayHighlight: true,
orientation: "top auto",
todayBtn: true,
todayHighlight: true,
});
//set input/textarea/select event when change value, remove class error and remove text help block
$("input").change(function(){
$(this).parent().parent().removeClass('has-error');
$(this).next().empty();
});
$("textarea").change(function(){
$(this).parent().parent().removeClass('has-error');
$(this).next().empty();
});
$("select").change(function(){
$(this).parent().parent().removeClass('has-error');
$(this).next().empty();
}); });
Really appreciate for your help
Answers
Hi @tamtamkidz ,
This will your server-side script failing - that error seems pretty explicit:
The error is saying that
group_start()
method couldn't be found - so that's the place to start. See if it's there, if it's in scope, etc..Cheers,
Colin