⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Search ALL not working for non-database column in flexigrid



lherlaar
  • profile picture
  • Member

Posted 19 May 2012 - 09:06 AM

Hi,

I just noticed the following issue:
When showing a column in list view that does not exist as a field in the database, the search ALL in flexigrid doesn't work.

As a test, I created a table test with two fields, field1 and field2. I defined field1, field2 and a non-database field concat as columns for the list view. I also define a callback function for the concat column that returns the concatenation of field1 and field2.


function concat_field1_field2($value = '', $row) {
return $row->field1 . ' - ' . $row->field2;
}

function test() {
$this->grocery_crud->columns('field1', 'field2', 'concat');
$this->grocery_crud->callback_column('concat', array($this, 'concat_field1_field2'));
...
}


If I use the flexigrid search and select a search in field1 or field2 only, it works as expected, but if I select search all, the search does nothing at all. However, if I create a database field concat the search all does work, even if the database contains no data for the concat field.

Thanks for looking into this!

(BTW could you please set my global upload quota to more than 500Kb? I can't upload a screenshot showing this issue.)

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 19 May 2012 - 10:20 AM

Yes you are right. The only thing that I can think right now is to do it like this:


function concat_field1_field2($value = '', $row) {
return $row->field1 . ' - ' . $row->field2;
}
function test() {
$this->grocery_crud->columns('field2');
$this->grocery_crud->callback_column('field1','field2', array($this, 'concat_field1_field2'));
...
}


like a workaround. But it will only search about field2 at this.

It is the only quick fix that I can think right now. I know that it is not exactly what are you looking for, but as long as grocery CRUD doesn't support custom queries yet this is the only quick solution. I try to do my best to find solutions for custom queries (simple or complex ones) as they are lot of users asking me this.

Of course you can always use the set_model method to add your own query at the list ( http://www.grocerycrud.com/documentation/options_functions/set_model ) but I think this will just make it more complicated for you.