Sorry - got again lost in the project work.
Here is one of the piece of code where i worked for search with column callback.
<?php
function lists() {
if(isset($_POST['search_field'])) {
$searchFields = $_POST['search_field'];
$searchValues = $_POST['search_text'];
$key = array_search('partner_assigned_to', $searchFields);
if($key !== false) {
$searchFields[$key] = 'emp_first_name';
$_POST['search_field'] = $searchFields;
}
}
//Here partner assigned to is populated with column callback -- where the value going to be first_name / last_name of employee
//What used to happen was - when the user searched in for the text - GC library used to ignore the search on the partner assigned to -
// as it is not a field in actual. So what i did in here - if i found the search as option, and user tried to search a user in the
//partner_assigned_to - i rather preferred to make user look up for the actual field.
$data = array();
$this->load->library('grocery_crud');
$CI =& get_instance();
$CI->load->library("session");
$CI->load->library("location");
$session = $CI->session->userdata('logged_in');
$crud = new Grocery_crud();
$crud->set_theme('bootstrap');
$crud->set_table('trade_partners');
$crud->callback_column('partner_assigned_to',array($this,'_cb_col_full_name'));
$crud->where('(partner_type = "KP+")');
foreach ($this->config->item('display_as_trade_partners') as $fields) {
list($field_name, $title) = $fields;
$crud->display_as($field_name, $title);
}
if($crud->getState() == 'read')
$crud->set_relation('created_by', 'user_profiles', '{upro_first_name} {upro_last_name}');
if(isset($_POST['search_field'])) {
$searchFields = $_POST['search_field'];
$searchValues = $_POST['search_text'];
$key = array_search('emp_first_name', $searchFields);
if($key !== false) {
$crud->or_like('trade_partners.emp_last_name', $searchValues[$key]);
}
}
//Now here if you notice, what i did was = looked up for the emp_first_name in searchfields list, (gc is anyways going to search for it)
//but there was 1 more value that i wanted to search along with - the emp_last_name too .. so i added my or like condition
$crud->order_by('id', 'desc');
if($session['user_level']!=1) {
$where = $this->location->getDataForList();
$crud->where($where);
}
$crud->hide_search('shop_email');
$crud->hide_search('mobile');
$output = $crud->render();
$data = buildData();
$this->stencil->layout('crud_layout');
$output->data=$data;
$this->stencil->paint("crud.php", $output);
} ?>
I am here just giving an example as how we can go ahead giving in desired solution. Every coder is a creative person who can come up with his / her creative solutions. This is just an example.