Jump to content


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

bootstrap theme where filter column filtering

  • Please log in to reply
9 replies to this topic

#1 marc_soad

marc_soad

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 14 August 2015 - 03: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

 



#2 XemmeX

XemmeX

    Newbie

  • Members
  • Pip
  • 7 posts

Posted 14 August 2015 - 08: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:



#3 marc_soad

marc_soad

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 20 August 2015 - 04: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().



#4 pandacin

pandacin

    Newbie

  • Members
  • Pip
  • 1 posts

Posted 22 August 2015 - 11: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



#5 XemmeX

XemmeX

    Newbie

  • Members
  • Pip
  • 7 posts

Posted 24 August 2015 - 03: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)



#6 marc_soad

marc_soad

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 27 August 2015 - 02: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!



#7 Freddy Sidauruk

Freddy Sidauruk

    Member

  • Members
  • PipPip
  • 10 posts

Posted 29 August 2015 - 02:52 AM

is it solved ?



#8 crackdcode

crackdcode

    Newbie

  • Members
  • Pip
  • 6 posts

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



#9 kyo

kyo

    Newbie

  • Members
  • Pip
  • 1 posts

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');


#10 Amit Shah

Amit Shah

    grocery CRUD Master

  • Advanced Member
  • PipPipPip
  • 1,192 posts
  • LocationMumbai, India

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 :)







Also tagged with one or more of these keywords: bootstrap theme, where, filter, column filtering

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users