Multipe Combo box Query System

11 views
Skip to first unread message

PalaniKannan K

unread,
Sep 23, 2010, 2:57:05 AM9/23/10
to Ruby on Rails: Talk
Hi,

Anybody tell me, how i can implement multiple query system which is related hierarchically ?

Like
1. Year,
2. Files in that selected year.

--
With Regards
Palani Kannan. K

Colin Law

unread,
Sep 23, 2010, 3:54:21 AM9/23/10
to rubyonra...@googlegroups.com
On 23 September 2010 07:57, PalaniKannan K <kpalan...@gmail.com> wrote:
> Hi,
>
> Anybody tell me, how i can implement multiple query system which is related
> hierarchically ?
>
> Like
> 1. Year,
> 2. Files in that selected year.

I think you will need to be a lot more specific about your
requirement. I, for one, have little idea what you mean. If you are
just talking about related tables (has_many, belongs_to etc) then have
a look at the Rails Guide on ActiveRecord Relationships.

Colin

PalaniKannan K

unread,
Sep 23, 2010, 6:52:26 AM9/23/10
to rubyonra...@googlegroups.com
Dear Collin,

Sorry for failing in explaining the problem. I wish to apply like

1. collection_select (country)
2. collection_select (state)
3. collection_select (city)

I need to give the query system hierarchically.

(Eg. select India -> then it should populate states in India-> select state tamilnadu-> it should populate cities in tamilnadu-> select madras-> It should get all params values as params[:country], :params[:state], :params[city]->@list = Table.find(conditions...params[:country], :params[:state], :params[city]))

This is the exact problem I need. In tutorials, this kind of hierarchal collection_select options are not available... If clear tutorials available kindly tell me... With Advanced Thanks.


--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonra...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Ar Chron

unread,
Sep 23, 2010, 10:41:29 AM9/23/10
to rubyonra...@googlegroups.com
You should look into:

http://stackoverflow.com/questions/575862/rjs-using-observe-field-on-select-tag

for info on how to use observe_field in combination with a select. I
just did a sursory review, and it looks like a decent solution
guideline.

--
Posted via http://www.ruby-forum.com/.

JeffV

unread,
Sep 27, 2010, 1:59:18 AM9/27/10
to Ruby on Rails: Talk


On Sep 23, 3:52 am, PalaniKannan K <kpalanikan...@gmail.com> wrote:
...
> 1. collection_select (country)
> 2. collection_select (state)
> 3. collection_select (city)
...
> (Eg. select India -> then it should populate states in India-
...
You can add onchange to 1 and 2 above, eg.
collect_select( ...,
:onchange=>
remote_function(:url=>controllers_path, :method=>:get,
:with=>''
'country='+options[selectedIndex].value" ) )

where "controllers_path" is a path to an action that,

Or you could write some unobtrusive jQuery code to perform similarly.

Jeff

PalaniKannan K

unread,
Sep 27, 2010, 4:05:32 AM9/27/10
to rubyonra...@googlegroups.com
Dear Jeff,

Thank you very much... Excellent.


--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonra...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Sunny Ezror

unread,
Sep 27, 2010, 5:07:16 AM9/27/10
to rubyonra...@googlegroups.com
Ryan Bates did an excellent screencast that does exactly just that:
http://railscasts.com/episodes/88-dynamic-select-menus

Supposedly this plugin does the same thing
http://github.com/splendeo/dependent_select

Haven't tried it personally, so can't vouch for it.

-sunny
http://ezror.com

Reply all
Reply to author
Forward
0 new messages