⚠ 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

Bootstrap theme column filtering not working with "OR" in where clause



marc_soad
  • profile picture
  • Member

Posted 14 August 2015 - 15:37 PM

Hi guys, first post here :)

 

I recently bought the Bootstrap Theme and I love it.

 

Unfortunately, I think I found a bug and I am searching for a fix or a workaround.  Here it is:

 

When i use 

->or_where() 

 or 

->where("field = value OR field = value2")

to pre-filter the a table view, the filtering at the top of each column doesn't work anymore.

 

Here are two samples of code where i'm having this issue:

$this->grocery_crud->set_table('inspection_planification_projects')
                        ->set_subject('un Projet')
                        ->unset_columns('idprojet', 'date_potentielle_visite','no_lot','nomProjet')
                        ->set_relation('plan','accreditation_plan_types', 'label')
                        ->where('(date_potentielle_visite IS NULL OR date_potentielle_visite = "") AND (date_rappel < CURRENT_DATE OR date_rappel IS NULL OR date_rappel = "") AND date_habite IS NULL OR date_habite = ""')
                        ->unset_add()
                        ->unset_delete()
                        ->unset_read();
$this->grocery_crud->set_table('inspection_planification_projects')
                        ->set_subject('un Projet')
                        ->unset_columns('idprojet')
                        ->set_relation('plan','accreditation_plan_types', 'label')
                        ->where('date_potentielle_visite', NULL)
                        ->or_where('date_potentielle_visite','')
                        ->unset_columns('date_potentielle_visite')
                        ->unset_add()
                        ->unset_delete()
                        ->unset_edit()
                        ->unset_read();

Any thoughts?

 

Thanks,

 

Marc

 


XemmeX
  • profile picture
  • Member

Posted 14 August 2015 - 20:20 PM

Hello Marc,

It's funny, we ran into the same problem today and earlier this morning, nobody was talking about it on the forum!
 
The search in the GRID of bootstrap theme no longer works properly, this when we add a simple WHERE statement!
 
$crud->where('inspection_status','0')
->or_where('inspection_status','1')
->or_where('inspection_status','6')
->or_where('inspection_status','9');

No matter what I try, I have no idea what is causing this problem!

Hope someone can help Us... HELP PLEASE  :unsure:


marc_soad
  • profile picture
  • Member

Posted 20 August 2015 - 16:05 PM

it works for me with a simple ->where().  The bug occurs when I add an OR inside a ->where() or I use ->or_where().


pandacin
  • profile picture
  • Member

Posted 22 August 2015 - 23:33 PM

I also just brought Bootstrap Theme recently, I also encounter this bug on bootstrap theme, add a normal $crud->where('customer_id', $id); then the filter button on top right will become not function


XemmeX
  • profile picture
  • Member

Posted 24 August 2015 - 15:10 PM

Because I can not afford the luxury of wasting time, I decide to replace the Bootstrap theme by the original datatables theme, that I have modified to match the style of the bootstrap, by reorganizing the look and feel of it! Now everything works, even with many set_relation on the same table and many WHERE, OR_WHERE statements.  B)


marc_soad
  • profile picture
  • Member

Posted 27 August 2015 - 14:14 PM

the problem with the original datatables is you can't filter on multiple columns at the same time... which is an important feature for me!


Freddy Sidauruk
  • profile picture
  • Member

Posted 29 August 2015 - 02:52 AM

is it solved ?


crackdcode
  • profile picture
  • Member

Posted 28 June 2016 - 09:59 AM

also bought the bootstrap theme recently and it is not even filtering  :unsure: - can somebody help me..thanks


kyo
  • profile picture
  • Member

Posted 06 September 2017 - 04:05 AM

 

Hello Marc,

It's funny, we ran into the same problem today and earlier this morning, nobody was talking about it on the forum!
 
The search in the GRID of bootstrap theme no longer works properly, this when we add a simple WHERE statement!
 

$crud->where('inspection_status','0')
->or_where('inspection_status','1')
->or_where('inspection_status','6')
->or_where('inspection_status','9');

No matter what I try, I have no idea what is causing this problem!

Hope someone can help Us... HELP PLEASE  :unsure:

 

try to use
 
$crud->where('inspection_status in ','(0,1,6,9)');
 
instead of 
 
$crud->where('inspection_status','0')
->or_where('inspection_status','1')
->or_where('inspection_status','6')
->or_where('inspection_status','9');

Amit Shah
  • profile picture
  • Member

Posted 06 September 2017 - 04:50 AM

Good 1 KYO.

 

Well.. 1 thing i too will like to comment on the same, when you use or_where( ... condition ...)  or even where condition ...

IRespective of what you search from the top of bootstrap theme later, the where condition will always be present with all the criterias in use.

 

The issue that might be happening will be @the generation of query ...

if u notice the output of the query being generated, you may see the where clauses with regular AND and an OR in middle. Now, such a query may tend to create a misleading output. if i were to suggest the better outcome, i will recommend a OR condition be placed up in the bracket ensuring it is filtering the output as expected.

 

Happy GCing :)