Code Monkey home page Code Monkey logo

ignited-datatables's People

Contributors

aazbeltran avatar brandonnoad avatar cryogenix avatar frypan-handler avatar geenasuresh avatar ikarius6 avatar jacq avatar jtrainaldi avatar mexx77 avatar n1crack avatar pestlett avatar petroz avatar rodolfosilva avatar ronelbojos avatar scorpile avatar vachzar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ignited-datatables's Issues

GROUP_CONCAT in filter error

hi,

here is the fix i have add to make group concat working:

public function select($columns, $backtick_protect = TRUE)
{
  foreach($this->explode(',', $columns) as $val)
  {

    /*GROUP CONCAT FIX JJ*/
    $finder = strpos($val,"GROUP_CONCAT");

    $column = trim(preg_replace('/(.*)\s+as\s+(\w*)/i', '$2', $val));
    $this->columns[] =  $column;
    if ($finder!==false){
      $this->select[$column] =  trim(preg_replace('/(.*)\s+as\s+(\w*)/i', '$2', $val));
    }else{
      $this->select[$column] =  trim(preg_replace('/(.*)\s+as\s+(\w*)/i', '$1', $val));
    }
  }

mysql ...GROUP_CONCAT(codice,"") as center...

Before this fix, the filter where using the search on the function istead of the "as" value,
pratically were: group_concat(codice,"") like %finding%
while i needed
center like %finding%

Hope this will help somebody, maybe you can reintegrate the source with a better coding

J

Error with LIKE in postgresql

When you try to perform a search the query fails if the selected column it's not a string.
LIKE pattern matching in postgresql only accept strings types

I solved my issue casting the field to varchar at line 228.

$sWhere .= $this->select[$mColArray[$i]] . "::varchar LIKE '%" . $sSearch . "%' OR ";

This fix works only for postgresql and it must be implemented differently in order to fix this issue

custom GROUP BY

Hi,

I need custum GROUP BY functionality so I added this function to Datatables.php
Unfortunately, the total results are then incorrect (result is alway 1). How can I resolve this, such that the correct number of rows is displayed?

Thanks, Max

/**
* Generates a custum GROUP BY portion of the query
*
* @param string $val
* @return mixed
*/
public function group_by($val)
{
   $this->group_by[] = $val;
   $this->ci->db->group_by($val);
   return $this;
}

I added to lines to get_total_results():

foreach($this->group_by as $val)
        $this->ci->db->group_by($val);

and added at the top an array:

protected $group_by       = array();

But now I always get 1 as a result... ?

How to implement like in Ignited Datatables while building query

how to implement Where and Like using Ignited Datatables for codeigniter while building query to get result.

Code i have tried is below:

$meter_id="12345";
$meter_id="'%".$meter_id."%'";
$this->datatables->select('Log_Name,Log_Creation_Date_Time,User_Name')
->from('Log_Data')
->where('Log_Name LIKE', $meter_id); //(Trying to Build LIke statement Here)
echo $this->datatables->generate();

OR

$meter_id="12345";
$this->datatables->select('Log_Name,Log_Creation_Date_Time,User_Name')
->from('Log_Data')
->like('Log_Name', $meter_id);
echo $this->datatables->generate();

But above both code was not working. i have also check the documentation of Ignited Datatables of Codeigniter but not found any example to bulid query with LIKE Keyword.

Query i have to build:

SELECT Log_Name,Log_Creation_Date_Time,User_Name FROM Log_Data
WHERE Log_Name LIKE '%12345%'

How could i will implement this?

Problem with rows

Hello,

I have a problem regarding the edit_column on datatables, it seems i cannot make the edit_column dynamic, what i mean with this, his to make the rows with different values.

For example:

if($var == 1){
$this->datatables->add_column('installed', "$installed","'custom_email()");
}else{
$this->datatables->add_column('installed', "$installed","'custom_email()");
}

Those variables are not values from the database.

Any given solution for this?

Cheers

Requested unknown parameter

When I load my page with CI Datables 2.0 beta, I received this message. When I use an older version of Datables no warning or error message appears. Is version 2.0 backwards compatible?

Requested unknown parameter '0' for row 0

Problem with short if statement on add_column

Having trouble adding a disabled state to a button and think it should work ok, but it's not.

$user_id is brought in to the function with session data to the below:

add_column('Action','<td><a href="' . base_url('users/view/$1') . '" class="btn btn-primary btn-xs">View</a>
                <a data-toggle="modal" href="' . base_url('users/delete/$1') . '" data-target="#modal-container" class="btn btn-danger btn-xs" ' . ($user_id == '$1' ? 'disabled="disabled"' : '') . '>Delete</a></td>','users.id');

I cannot get the disabled state to take even when say 48 == 48

Even tried using trim() on $user_id and $1

Very odd and not sure what I'm missing. Thoughts? Thanks much.

SQL Mode Grid

The necessary codes to be able to make sql based grid generations are still missing.

Any examples?

I'm fairly new to jQuery (started about 4 months ago), but not new to CodeIgniter. I'm confused on how to integrate Datatable's server-side functionality... even with your library. Are there any posted examples I can look at?

I've got the Datatable's basic functionality down just by copying/pasting from their examples but I don't know how to tie in your library.

not_like method

I think it would be useful if there was a not_like function that works the opposite of the like.

improper column parsing of multiline sql statements

If I have a multiline statement, which in this case was an ugly MySQL CASE usage:

CASE
  WHEN foo = bar  
  THEN baz
 END
 AS column_alias

In the regex that accounts for parsing columns via regex:

public function select($columns, $backtick_protect = TRUE)
{
  foreach($this->explode(',', $columns) as $val)
  {
    $column = trim(preg_replace('/(.*)\s+as\s+(\w*)/i', '$2', $val));
    $this->columns[] =  $column;
    $this->select[$column] =  trim(preg_replace('/(.*)\s+as\s+(\w*)/i', '$1', $val));
  }

  $this->ci->db->select($columns, $backtick_protect);
  return $this;
}

The 'END' in the funky statement above is being removed due to newlines (\n).

If the column statements are pre-parsed via another regex for liable break statements such as \n, \r, \r\n, \t, etc., then this would not be an issue.

Great library, thank you!

mysql_real_escape_string error on line 290

I use MSSQL as my database, and have MySQL disabled, so this call was breaking. However, I was able to use the CodeIgniter escape_like_str to fix it.

    protected function get_filtering()
    {
      if ($this->check_mDataprop())
        $mColArray = $this->get_mDataprop();
      elseif ($this->ci->input->post('sColumns'))
        $mColArray = explode(',', $this->ci->input->post('sColumns'));
      else
        $mColArray = $this->columns;

      $sWhere = '';
      $sSearch = $this->ci->db->escape_like_str($this->ci->input->post('sSearch'));
      //$sSearch = mysql_real_escape_string($this->ci->input->post('sSearch'));
...

Problem with edit_column function

Hi, first of all what a great library you have. However there is bug with the function edit_colum (and I suppose in add_colum) and it as follow: when I try to use for example edit_colum and the value can be 0 or 1 from the database, and here is the problem what if when the value is 0 I want to print "Inactive" and when is 1 print "Active", checking the library I noticed that It simply replace $1, but how I can manage that king of validation.

here is a code example:

$this->datatables->select('intId,strNombre,strEmail,enmTipo,intEstado')
//->unset_column('intId')
//->unset_column('avatar')
->edit_column('intId', '','intId')
->edit_column('intEstado',$this->get_estado('$1'),'intEstado')
->from('tbl_usuarios');

    echo $this->datatables->generate();

private function get_estado($estado)
{
return $this->load->view('template/label_estado.php',array('tipo'=>array('0'=>'success','1'=>'warning'), 'estado'=>'Activo','est'=>$estado),true);

}

the view:
span class="label label-"></span

I hope this example is good enough to understand what I say. How can I implement some kind of validation to modify the view I want to display.

Thanks in advance.

High Page Load

I found that when Ignited Tables is getting data it requests also the total number of records:

$iTotal = $this->get_total_results();
$iFilteredTotal = $this->get_total_results(TRUE);

This performs two querys to get only the count.
I've replaced bought variables with static numbers like:

$iTotal = 10;
$iFilteredTotal = 2300;

The page load reduced from 8 seconds to 400 ms.
This is a big issue, is taking a high load to get only the count.

How to add function to add_column?

In my additional colums I want to display confirm button only if value of 'status' from database is 'no'.

So my additional column should look like this:

->add_column('button', '<a class="btn btn-mini btn-warning" data-toggle="modal" href="#?page=customers-database&id=$1&action=confirm">Confirm</a>', 'face_id')

How to attach below function to above code?

function customer_confirmed($status,$id)
{
  if($status=='Yes'){$output='Confirmed';}
  if($status=='No'){$output='<a class="btn btn-mini btn-warning" data-toggle="modal" href="#?page=customers-database&id=$id&action=confirm">Confirm</a>';}
  return $output;
}

function get_total_results

Hello... I have 2 datatables ajax in same page, but the sInfo sInfoEmpty sInfoFiltered are : $rResult = $this->get_display_result();
$iTotal = $this->get_total_results();
$iFilteredTotal = $this->get_total_results(TRUE);
show me same results, but the querys are not equals.

Any suggestions to help me ? Thanks !

Issue with edit_column

helper function i created:
function is_comm($check)
{
if($check)
return 'Yes';
else
return 'No';
}

Now with ignited table i code in controller:
$this->datatables
->select('fee_id, fee_name, fee_is_comm, fee_remarks')
->unset_column('fee_id')
->edit_column('fee_is_comm', is_comm('$1'), 'fee_is_comm')
->from('fee_types');

But the helper function treating the $check as string ('$1') which is actually Boolean (0|1) from database. It always return "Yes".
See the issue if we can fix it.

Datatable just displaying loading

Datatable is just showing loading and i discovered that request is made using GET but the library was designed to work with post, i tried to do a search and replace from $this->ci->input->post() to $this->ci->input->get_post() it started displaying but i was only getting two rows from a total of 250 rows in my table.

Date range + Ignited-Datatables

Hi, I love your project, and I actually use it, but I had a little problem... I use Column Filter (http://code.google.com/p/jquery-datatables-column-filter/wiki/ColumnFilter) and exist a filter type named "date-range", when you add it, it creates 2 inputs (with datepicker plugin) and send something like this
sSearch_xx = 12/07/1312/07/13
or
sSearch_xx = 12/07/13

or
sSearch_xx = ~12/07/13

I saw your code, and you do the filter of consults in get_filtering(), so I edited your code in the part

if(preg_match("/(<=|>=|=|<|>)(\s*)(.+)/i", trim($val), $matches))
$this->ci->db->where($this->select[$mColArray[$i]].' '.$matches[1], $matches[3]);
else
$this->ci->db->where($this->select[$mColArray[$i]].' LIKE', '%'.$val.'%');

For the next one:

if(preg_match("/(<=|>=|=|<|>)(\s_)(.+)/i", trim($val), $matches))
$this->ci->db->where($this->select[$mColArray[$i]].' '.$matches[1], $matches[3]);
else if(preg_match("/(._)$sRangeSeparator(.*)/i", trim($val), $matches)){
if(!empty($matches[1]))
$this->ci->db->where($this->select[$mColArray[$i]]." >= '".$matches[1]."'");
if(!empty($matches[2]))
$this->ci->db->where($this->select[$mColArray[$i]]." <= '".$matches[2]."'");
}else{
$this->ci->db->where($this->select[$mColArray[$i]].' LIKE', '%'.$val.'%');
}

I added one "if" than search the separator $sRangeSeparator (in datatables named "sRangeSeparator") what be ~ .... to be more generic, I hadded the line:

$sRangeSeparator = $this->ci->input->post('sRangeSeparator');

Before the new "if", so... with that, date-range can works :) cheers.

Datatables "Show All" (-1) always limited to 10

I was wondering if there was a reason we are limiting the -1 magic "Show All" option to only show 10 (used to be 100).

I rewrote the if statement to just ignore the limit if it's not set or if it's the magic number.

Old:

    private function get_paging()
    {
      $iStart = $this->ci->input->post('iDisplayStart');
      $iLength = $this->ci->input->post('iDisplayLength');
      $this->ci->db->limit(($iLength != '' && $iLength != '-1')? $iLength : 10, ($iStart)? $iStart : 0);
    }

New:

    private function get_paging()
    {
      $iStart = $this->ci->input->post('iDisplayStart');
      $iLength = $this->ci->input->post('iDisplayLength');
      if(($iLength != '' && $iLength != '-1')) {
        $this->ci->db->limit( $iLength, ($iStart)? $iStart : 0);
      }
    }

no support for where_in?

i am using ignited datatables, i want to use a query with where_in function, the codeigniter do supports the where_in but ignited-datatables has no support for where_in function..

Please can anyone fix this issue.

Really need this function..

group_by and order_by don't work when I use both in a query

At first, Thanks for a wonderful library. I have a situation where I have to join 2 table and I have to use join and group_by function to join with the latest row of a group of rows.

But when I try to use that don't work.

Would you please give me a solution of that.

Thanks

Manipulate query result

I have an addition to the Ignited Datatables. It's on my fork:
https://github.com/blagi/Ignited-Datatables/
I don't know how to post it here. Please help. Also some testing, style modification and integration to this original are welcomed.

Added public var $queryResult. Added two public methods:
generateResult() and produceOutputFromResult().
Now Datatables can be
called in another way:

$this->load->library("Datatables");

$this->datatables
->select("id as DT_RowId, email, last_login")

->from('user');
// echo $this->datatables->generate();
$raw_data = $this->datatables->generateResult();
foreach ($raw_data->result() as $row) {
$row->last_login_display = date('d.m.Y H:i', strtotime($row->last_login));
}
$res = $this->datatablesb->produceOutputFromResult();
echo $res;

Error when it has the same name in two different tables.

In a query
$this->datatable
->select('a.name, b.name')
->from('tableA a')
->join('tableB b', 'b.id_tableA = a.id');

$this->datatable->generate();

it does not work.

The message:
Severity: Notice
Message: Undefined offset: 2
Filename: libraries / Datatables.php
Line Number: 476

thank you

Table Joins

The ability to generate data based on join statements.

Date Range Filtering for Specific Column with CodeIgniter

Hello,
I want to ask about daterange filtering using codeigniter in datatables.
I'm using the library Datatables for codeigniter.
But, I don't know how to configure my view for passing parameter (startdate and enddate) to the controller. So, it can be filtered by daterange.
Can anyone help me?

Thanks in advance.

Can not filter an integer field for value of zero

When searching an integer field for value of zero, no search is performed. Any other value besides zero works perfectly.

The filter property is empty at line 250 in the get_filtering method.

This is the query created:

"SELECT `personid`, `agency_name`, `poc_1_last_name` as poc_name, `poc_1_first_name`, 
`physical_state`, `last_updated`, `date_created`, `status_flag`
FROM (`canpoc`) 
ORDER BY `personid` asc LIMIT 10"

All post vars are confirmed and correct at the server.

Group_concat filtering causing error SQL

When using Group_CONCAT in the query, filtering will having an issue.

Below is hacking the get_filtering function but works, it will also filtering the fields with group_concat, however, the downside is that you will have to group_concat and distinct every field that you wish to search for.

See if you can find a better approach for group_concat

$sWhere = '';
$qHaving = '';
$sSearch = $this->ci->db->escape_like_str(trim($this->ci->input->post('sSearch')));
$mColArray = array_values(array_diff($mColArray, $this->unset_columns));
$columns = array_values(array_diff($this->columns, $this->unset_columns));

  /*if($sSearch != '')
    for($i = 0; $i < count($mColArray); $i++)
      if($this->ci->input->post('bSearchable_' . $i) == 'true' && in_array($mColArray[$i], $columns))
        $sWhere .= $this->select[$mColArray[$i]] . " LIKE '%" . $sSearch . "%' OR ";*/
  if($sSearch != '')
    for($i = 0; $i < count($mColArray); $i++){
      if($this->ci->input->post('bSearchable_' . $i) == 'true' && in_array($mColArray[$i], $columns))
        if (strpos($this->select[$mColArray[$i]],"GROUP_CONCAT")===false) {
          $sWhere .= $this->select[$mColArray[$i]] . " LIKE '%" . $sSearch . "%' OR ";
        } else {
          $qHaving .= $this->select[$mColArray[$i]] . " LIKE '%" . $sSearch . "%' OR ";
        }
    }

  $sWhere = substr_replace($sWhere, '', -3);
  $qHaving = substr_replace($qHaving, '', -3);

  if($qHaving != '') {
    $this->ci->db->having('(' .$qHaving . ')');
    $sWhere = '';
  }    

Error

Codeigniter Error :

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE (datouno LIKE '%es%' OR datodos LIKE '%es%' OR datotres LIKE '%es%' OR dat' at line 2

SELECT COUNT(*) AS numrows WHERE (datouno LIKE '%es%' OR datodos LIKE '%es%' OR datotres LIKE '%es%' OR datocuatro LIKE '%es%' OR datocinco LIKE '%es%' )

Bug with CI 2.2.0

Using postgress "PostgreSQL 9.1.9 on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-54), 64-bit"

On my controller the order_by does not work

    ->from('my_table')
->order_by('my_tableid', 'desc');

It gives me a blank (white PHP page)

Tried updating to libraries/datatables.php 2.0 beta but still there's an issue.

more options

we can send 4th parameter as options. it would be like;

  $jointables["user_groups"]["columns"] = array("group_name");
  $jointables["user_groups"]["fk"] = "users.plevel = user_groups.plevel";
  $options["jointables"] = $jointables;

  $custom_columns["edit"] = array("<a href='pages/edit/$1'>Edit</a>",array("users.id"));
  $custom_columns["delete"] = array("<a href='pages/delete/$1'>Delete</a>",array("users.id"));
  $options["custom_columns"] = $custom_columns;

  $options["custom_filter"] = "users.plevel=2";  //  while listing only admins or moderators
     // or 
  $options["custom_filter"] = "pages.cat_id=23"; // while listing a certain category's pages

and 4th parameter would be "$options".

Documentation

I am using your library, very helpfull. I just come back again to check the documentation, couldnt find it.

Where can i remember the use of the functions?

Problem returning a view edit_colunm or add_colunm

I'm trying to make a call_back bring me a view in the datatable but I get a problem this is my code:

Model

    public function usuarioDataTableJson()
    {   
        // We loaded the helper that generates buttons
        $this->load->helper('botones');
        $this->datatables
        ->select("usuarioId AS checkbox, usuarioId, usuario, perfil, empleado, empresa, departamento", FALSE)
        ->from('vista_usuarios')
        ->edit_column('checkbox', '<label><input type="checkbox" class="ace" name="usuarios[]" value="$1" /><span class="lbl"></span></label>', 'usuarioId')
        ->add_column('action', '$1', 'crearBotonAccion(usuarioId, "usuario", empleado, "editar")');

        return $this->datatables->generate();
    }

Helper

    function crearBotonAccion($ID=0,$modulo='',$titulo='',$accion='')
    {   
        $CI =& get_instance();
        $CI->load->library('session');
        $arrayKey= array();
        $data = array();
        foreach ($CI->session->userdata('SubModulos') as $value) {
                $arrayKey =  array(
                    'agregar' => $value->agregar,
                    'ver' => $value->ver,
                    'editar' => $value->editar,
                    'eliminar' => $value->eliminar,
             );
                $data = array(
                    'urlAgregar' =>base_url().strtolower($titulo).'/'.$accion,
                    'url' => base_url().strtolower($titulo).'/'.$accion.'/'.$ID,
                    'titulo' => strtolower($titulo),
                    'accion' => $accion,
                    'id' => $titulo."_".$accion,
                 );
            if($value->nombre == $modulo && $arrayKey[$accion] =='si')
            {

                return $CI->load->view("botones/".$accion, $data);

            }       
        }
    }

If it can be noted in the method we introduce edit_column HTML, here everything goes well

edit_column('checkbox', '<label><input type="checkbox" class="ace" name="usuarios[]" value="$1" /><span class="lbl"></span></label>', 'usuarioId')

But the method add_column where I have a function that returns me a view instead of retornarme html, I get an error

->add_column('action', '$1', 'crearBotonAccion(usuarioId, "usuario", empleado, "editar")')
return $CI->load->view("botones/".$accion, $data);

Running Custom-Querys? / Or usage of 'UNION' ?

I need to get results of multiple tables without using joins, like this:

(SELECT id, foo, bar, name FROM table_1)
UNION
(SELECT id, foobar, barfoo, name FROM table_2)
UNION
(SELECT id, barzoo, foobarz, name FROM table_3)

Is there a way to do this with Ignited-Datatables?

total_result error when using distinct()

i found that when use distinct() in query, total result will return whole total table not the total distinct one.

protected function get_total_results($filtering = FALSE){
    if($filtering)
        $this->get_filtering();
    foreach($this->joins as $val)
        $this->ci->db->join($val[0], $val[1], $val[2]);
    foreach($this->where as $val)
        $this->ci->db->where($val[0], $val[1], $val[2]); 
    return $this->ci->db->count_all_results($this->table);
}

and I trace the code and change to this code below then it work fine :)

protected function get_total_results($filtering = FALSE)
{
  if($filtering)
     $this->get_filtering();
  $this->ci->db->distinct();
  $this->ci->db->select($this->columns, TRUE);
  foreach($this->joins as $val) $this->ci->db->join($val[0], $val[1], $val[2]);
  foreach($this->where as $val) $this->ci->db->where($val[0], $val[1], $val[2]);
  $this->ci->db->from($this->table);
  return $this->ci->db->get()->num_rows();
}

get_total_results very slow on large tables

I propose the following changes:

if(strlen($this->distinct) > 0)
{
$this->ci->db->distinct($this->distinct);
$this->ci->db->select($this->columns);

$query = $this->ci->db->get($this->table, NULL, NULL, FALSE);
return $query->num_rows();

}
else
{
$this->ci->db->select('count(0) num_rows');
$query = $this->ci->db->get($this->table, NULL, NULL, FALSE);

$res = $query->result();
return $res[0]->num_rows;

}

Filtering with query keyword breaks

In my db I have table with a column name 'add' which is a keyword. When I search on the datatables I was getting this error:

"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'add LIKE '%sd%' OR ..."

It seems backticks were not taken care of while preparing the query in get_filtering() function.

Fixed in by adding backtiks while preparing the query in get_filtering() on line 298:
As it is now:
$sWhere .= $this->select[$mColArray[$i]] . " LIKE '%" . $sSearch . "%' OR ";
As I changed it to:
$sWhere .= "".$this->select[$mColArray[$i]]."" . " LIKE '%" . $sSearch . "%' OR ";

Can not Use mysql reserve words as column name in where condition [solution]

Hi, found one bug we can not use mysql reserve words as columns in where condition with Ignited Datatables as you are using simple string as where or condition and i used key as column name

$sWhere .= $this->select[$mColArray[$i]['data']] . " LIKE '%" . $sSearch . "%' OR ";

to avoid this problem and use mysql reserve words as column name use the following CI database function $this->ci->db->_protect_identifiers($col_name)

$this->ci->db->_protect_identifiers($this->select[$mColArray[$i]])

$sWhere .= $this->ci->db->_protect_identifiers($this->select[$mColArray[$i]['data']]) . " LIKE '%" . $sSearch . "%' OR "; line no 298

$sWhere .= $this->ci->db->_protect_identifiers($this->select[$mColArray[$i]]) . " LIKE '%" . $sSearch . "%' OR "; line no 300 in your current library

Illegal mix of collations for operation 'like' while searching

I have successfully implemented Ignited-Datatables, works like a charm, thank you. However, while searching with database when typing "non-latin" characters like "İ,ş,ğ,.."

POST http://vproject.dev/module/user/ign_listing 500 (Internal Server Error)

Details are:

Illegal mix of collations for operation 'like' while searching

... (u.id_user LIKE '%Ä°%' OR u.first_name LIKE '%Ä°%' OR u.last_name LIKE '%Ä°%' OR ue.email LIKE '%Ä°%' OR u.last_login LIKE '%Ä°%' ) ...

'%Ä°%' part changes according to the non-latin character you typed.

Any idea for solving this?

$this->datatables->unset_column($column); not working

Expected behavior
$this->datatables->unset_column($column); should return all columns except the ones passed as a parameter.

Result
Passed column parameter still appears.

Fix
replace this $column=explode(',',$column);
with this $column=array_flip(explode(',',$column)); //:edit

Issue with make bold some row

$z='';
for($c=0; $c < sizeof($dis); $c++)
{
if($c==sizeof($dis)-1)
$z.=$dis[$c]->id_surat;
else
$z.=$dis[$c]->id_surat.", ";
// var_dump($z);
// var_dump($dis[$c]->baca);

    }

$z=0;
$this->datatables->select("id, nomorsurat, tanggal , pengirim, tertuju, sifatsurat");
$this->datatables->add_column('Actions', get_buttons('$1',$this->ulvl),'id');
$this->datatables->edit_column('nomorsurat',"$1","");

     $this->datatables->from('suratmasuk');
     $this->datatables->where("id in ($z)");
     echo $siap=$this->datatables->generate();        

if value baca is 0, then the row look bold, vice versa.
any idea?

Callbacks & Objects

Gear code !! But since I use the datagrid with some more php function styling & use object rather than arrays... I changed the generate part some to; Maybe someone finds it usefull or it could be ported in a new release?

var $callback;
protected function produce_output($charset)
{
  $aaData = array();
  $rResult = $this->get_display_result();
  $iTotal = $this->get_total_results();
  $iFilteredTotal = $this->get_total_results(TRUE);

  $result = $rResult->result();
  //Tune the data?
  $function = $this->callback;
  $function( $result);


  foreach($result as $row_key => $row_val)
  {
    $c = 0;
    foreach($row_val as $k => $v) {
        $row_val_arr[$c] = $v; 
        $c++;
    }
    $aaData[$row_key] = $row_val_arr;

  }

  $sColumns = array_diff($this->columns, $this->unset_columns);
  $sColumns = array_merge_recursive($sColumns, array_keys($this->add_columns));

  $sOutput = array
  (
    'sEcho'                => intval($this->ci->input->post('sEcho')),
    'iTotalRecords'        => $iTotal,
    'iTotalDisplayRecords' => $iFilteredTotal,
    'aaData'               => $aaData,
    'sColumns'             => implode(',', $sColumns)
  );

  if(strtolower($charset) == 'utf-8')
    return json_encode($sOutput);
  else
    return $this->jsonify($sOutput);
}

Now you can use the callback to php style your data as follows:
//Inside the class
....
$this->datatables->callback = "prettify";
$this->datatables->generate();

//Outside the Class
function prettify($result) {
foreach($result as $row) {
$row->website = auto_link($row->website, 'url', TRUE);
}

}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.