Welcome, Guest
Username: Password: Remember me

TOPIC: Multiple Select Filters?

Multiple Select Filters? 14 Oct 2013 20:03 #11391

  • dyoungers
  • dyoungers's Avatar
  • Offline
  • Premium Member
  • Posts: 123
  • Thank you received: 16
  • Karma: 0
I'd like to add a multiple select drop down filter to one of my list/grid views (it's being loaded from a foreign key), i.e. I'd like to subset the list using more than one foreign key value

Does anyone have an idea (just need a starting point) on how one could go about doing that?

Thanks!
Dave
The administrator has disabled public write access.

Multiple Select Filters? 15 Nov 2013 21:57 #11635

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
Hi Dave,

JDom? I'm eventually going to be doing this for a product attributes filter in the next month or s as part of a shopping cart extension. I haven't given it any more thought other than my presumption to begin by looking at the JDom class responsible for populating the filters options & markup then extend it to allow multiple selection.

Some changes will need to be made to the sql query to accommodate how you would like it to behave: are the conditions to be chained by 'OR' / 'AND' operators for example... Anyway, let us know how it goes and if you need anything else. Hope it helps a little!

Gez
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
The administrator has disabled public write access.
The following user(s) said Thank You: dyoungers

Multiple Select Filters? 20 Nov 2013 15:36 #11688

  • admin
  • admin's Avatar
  • Online
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
You will need to write both in JDom and in the component model.

JDom can display the control, but its role is limited to this.

JDom :
Extends a normal combo to a multi-checkable list.
-> html.form.input.select.multi (new class)

Override only few things to make a control sending an ARRAY in post.

In Component list model:
(Write the maximum you can in the super class)

In this list model in general, receive this array and set the filter state var, this is already done automatically :
Change the filter type to 'array' in the list model constructor.(not tested, but should work)

Then in prepareQuery, create the SQL filter.
For this particular purpose, a super-function could be awesome. (Such as 'propagateAccesses' SQL creation)

Hope it helps.
Coding is now a piece of cake
The administrator has disabled public write access.

Multiple Select Filters? 20 Nov 2013 15:40 #11689

  • admin
  • admin's Avatar
  • Online
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
Also...

When you reload the page, the filter must be able to display the current selected values.
This should be done automatically, but I never tested it with arrays.

If somebody is trying all this I would really enjoy to have your reviews.

Thanks again Gez for your help.
Coding is now a piece of cake
The administrator has disabled public write access.
Time to create page: 0.198 seconds

Get Started