Hi ! Peter Thanks for your feedback on my first post, I don't know whether you could solve your problem or not, as Amit Shah said there is no straight forward solution
available, but it can be achieved something like this, I did it in one of my projects, might help you too :)
Please note since we are comparing numbers (user_id), this method may not give you good search results,
for example if you search amit, it will return user_id 2, which is ok, suppose if you just search letter 'a', we actually expect it to list both amit and akshay, it will just return user_id 2 as it finds first in given array, so I will not tell that this method is best, its just a hint for you
In your controller create function or array which contains user_id and and user name, which looks something like this
/* do your db stuffs and return array */
function _get_users()
{
// Do your db stuffs here
return array(
1 => 'Peter',
2 => 'Amit Shah',
3 => 'Akshay',
4 => 'John',
5 => 'Dummy'
);
}
and another small function which compares partially for example
/* Compare if there is any match partially return user id, else some bad numbers */
function compare_user($search=NULL)
{
if(!is_null($search))
{
foreach($this->_get_users() as $k => $v)
{
if(strpos(strtolower($v),strtolower($search)) !== false){
return $k;
}
}
}
return -99;
}
Finally modify $_POST array, remaining things GC does :)
function test()
{
....
....
$crud->callback_column('user_id',array($this,'get_username'));
$crud->callback_field('user_id',array($this,'get_username'));
// If search field is user then do this
if(in_array($crud->getState(),array("ajax_list","ajax_list_info")) && array_key_exists("search_field",$this->input->post() ) )
{
if($this->input->post("search_field") === "user_id" && strlen($this->input->post("search_text")) )
{
$_POST["search_text"] = $this->compare_user($_POST["search_text"]);
}
}
....
....
$this->load->view('your_view',$crud->render());