I did some research on jQuery datatables wrapper [IgnitedDatatables] and made it working on a project to load huge data. One problem where i stuck was how to use callback function on edit columns. After several hours of try, i fixed it. Below is the solution on how i fixed it.
This post is not about how to use Ignited Datatables. I assume that you have working Ignited Datatables .
This example is taken from https://github.com/n1crack/IgnitedDatatables-php-library/blob/master/examples/callback_functions/ajax.php
$this->datatables->select('customer_id, first_name, last_name, email') ->from('customer') ->add_column('edit', 'Edit', 'customer_id') ->add_column('delete', 'Delete', 'customer_id') ->edit_column('email', '$1', strtolower('email')) // php functions ->edit_column('email', '$1', $this->custom_email('email')) // custom functions ->edit_column('first_name', '$1', $this->fix_first_name('first_name')); echo $this->datatables->generate();
// Callback Functions function custom_email($val) { return substr($val, 0, 3) . '..' . strstr($val, "@"); } function fix_first_name($val) { return ucwords(strtolower($val)); }
All credit goes codeigniter Ignited-Datatables library. You can download the library from https://github.com/IgnitedDatatables/Ignited-Datatables
source : http://developer-paradize.blogspot.com, http://twitter.com, http://log.viva.co.id
0 Response to "[Codeigniter] How To Use Callback Function In Ignited Datatables ?"
Post a Comment