filtering using OR criterea

45 views
Skip to first unread message

Tim Uckun

unread,
Mar 14, 2012, 11:04:42 PM3/14/12
to rails...@googlegroups.com
Is there a way to have OR in your filter criterea? It seems like every filter you add is ANDed.

Thanks.

Benoit Bénézech

unread,
Mar 15, 2012, 5:18:53 AM3/15/12
to rails...@googlegroups.com
No, you can't.

Tim Uckun

unread,
Mar 15, 2012, 5:52:22 PM3/15/12
to rails...@googlegroups.com
On Thu, Mar 15, 2012 at 10:18 PM, Benoit Bénézech
<benoit....@gmail.com> wrote:
> No, you can't.


Bummer. Is this feature planned at any point?

Benoit Bénézech

unread,
Mar 16, 2012, 6:29:23 AM3/16/12
to rails...@googlegroups.com
No; I think it would be hard to implement in the general case. (the UI would be really tricky, especially).

Now if you want to  'AND' or 'OR' ALL your filters, then you can pass the 'OR' as a param and hack smtg in the two adapters, quite easy. (both AR and Mongoid support it).

Tim Uckun

unread,
Mar 17, 2012, 11:50:45 PM3/17/12
to rails...@googlegroups.com
On Fri, Mar 16, 2012 at 11:29 PM, Benoit Bénézech
<benoit....@gmail.com> wrote:
> No; I think it would be hard to implement in the general case. (the UI would
> be really tricky, especially).

I have some old code that does this...

There is a drop down box with all the fields in it. When you click on
it it fills the "operatators" dropdown according to the type of the
field (greater than, contains etc). There is a box for the param.
After the param there is a dropdown box with "and, or" as options. If
you want another param you click and or or and it creates a new row
for the next filter. In your gui it would be easy enough to always
have a dropdown after the params with an AND or OR options.

For something even more sophisticated you can look at the jqgrid
advanced search functionality.

> Now if you want to  'AND' or 'OR' ALL your filters, then you can pass the
> 'OR' as a param and hack smtg in the two adapters, quite easy. (both AR and
> Mongoid support it).
>

Ideally I could pick and choose like date > X AND date < Y or date is
null but I can see where grouping might be handy too.

>>
>> Bummer. Is this feature planned at any point?
>

> --
> You received this message because you are subscribed to the Google Groups
> "rails_admin" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/rails_admin/-/H6uzPwt8S-AJ.
>
> To post to this group, send email to rails...@googlegroups.com.
> To unsubscribe from this group, send email to
> rails_admin...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/rails_admin?hl=en.

Benoit Bénézech

unread,
Mar 18, 2012, 11:19:53 AM3/18/12
to rails...@googlegroups.com
Sure, it's doable. If you have the time, you're very welcome ;-)
If you make it recursive (AND/OR mixed in same request), you'll have to update all three adapters (someone is working on DataMapper and might integrate it).

Tim Uckun

unread,
Mar 18, 2012, 6:28:15 PM3/18/12
to rails...@googlegroups.com
On Mon, Mar 19, 2012 at 4:19 AM, Benoit Bénézech
<benoit....@gmail.com> wrote:
> Sure, it's doable. If you have the time, you're very welcome ;-)
> If you make it recursive (AND/OR mixed in same request), you'll have to
> update all three adapters (someone is working on DataMapper and might
> integrate it).

If I have time I'll poke at it for a while and see what comes out.

Sherban Drulea

unread,
Mar 29, 2019, 6:07:07 PM3/29/19
to rails_admin
Hi. I need OR filters also. Has there been any update on this?
Reply all
Reply to author
Forward
0 new messages