⚠ 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

Multiple filter problem with GC when adding additional WHERE condition on ajax_list



ecx

ecx
  • profile picture
  • Member

Posted 31 January 2016 - 05:05 AM

Hi, 

 

I would like to ask for some help or maybe someone out there could point me to the right direction. 

 

I am new to using Grocery Crud and I have just started using GC on my project. 

 

What I am trying to do is to only show all items NOT marked as deleted so my table has a field called 'is_deleted' which have a default value of '0'.

 

I have added an additional where condition on my GC instance: 

$crud = new grocery_CRUD();
$crud->where('is_deleted', '0', true);
$crud->set_table($this->db->dbprefix('item'));

When the page first loads, it only shows all items that are not marked as deleted. Which is working as expected.

 

And on the list page, this option is not shown as a filter and should be hidden and default on the back-end. 

 

But when I start searching/filtering items the problem occurs. 

 

E.g: Search keyword is "test" and field is "ALL". GC returns all items from the table without applying any "where" condition as seen from the result being returned. 

 

Please also note that this only happens when the field selected is "ALL" but not when I set the field to a specific field the filtering works correctly. 

 

 

Any help/suggestion is highly appreciated. 

 

Thank you.


ecx

ecx
  • profile picture
  • Member

Posted 02 February 2016 - 11:37 AM

Upon searching for solution on this problem I have seen an Issue on github and Doctor-Paul's commented code has been able to solve the problem. 

 

For anyone who might encounter the same problem you may check it here: 

 

https://github.com/scoumbourdis/grocery-crud/issues/341

 

 

 

Cheers!