# Filtering of rows during selection

**URL:** <https://www.ruby-forum.com/t/filtering-of-rows-during-selection/178445>\
**Category:** Rails\
**Created:** [November 4, 2009, 8:12pm UTC](https://www.ruby-forum.com/t/filtering-of-rows-during-selection/178445 "2009-11-04T20:12:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jesterz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a4c791/32.png) [@Jesterz](https://www.ruby-forum.com/u/Jesterz)\
**Post date:** [November 4, 2009, 8:12pm UTC](https://www.ruby-forum.com/t/filtering-of-rows-during-selection/178445/1 "2009-11-04T20:12:19Z")

</div>

Hi all,  
I am new to rails, and for that matter programming for the web.  
Scenario:  
In a Purchase Order screen, I am trying to let a user (Fred) select a  
customer(General Hospital-MA) and some products.  
Typically, it can be done using a dropdown list to select from the  
customers (and products).

Our case:  
We have hundreds of customers, and thousands of products, so the  
dropdownlist is just not suitable.

What is was:  
In the olden days(I guess I belong there?), there would be a popup  
that shows CustomerCode and CustomerName and there would be 2 text  
fields above for the user to put in a few characters (with wildcard).  
Upon typing “hosp” (or “%hosp%” or “_hosp_”) and pressing “find”, the  
selection list would filter the data and show only those filtered  
records. User then chooses 1 from the much shorter list and it  
returns to the previous window, populating the other fields.

Question:  
How do I do the equivalent of this in Rails?  
It doesn’t have to be a popup or have a text field for filtering data  
or any of the traditional UI practices.  
It just has to give the user an easy way to select 1 from 1,000  
records very quickly.

Thanks.

---

<div class="post-metadata">

**Author:** ![Jesterz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a4c791/32.png) [@Jesterz](https://www.ruby-forum.com/u/Jesterz)\
**Post date:** [November 4, 2009, 9:03pm UTC](https://www.ruby-forum.com/t/filtering-of-rows-during-selection/178445/2 "2009-11-04T21:03:31Z")

</div>

Jesterz wrote:

> Hi all,  
> I am new to rails, and for that matter programming for the web.  
> Scenario:  
> In a Purchase Order screen, I am trying to let a user (Fred) select a  
> customer(General Hospital-MA) and some products.  
> Typically, it can be done using a dropdown list to select from the  
> customers (and products).
> 
> Our case:  
> We have hundreds of customers, and thousands of products, so the  
> dropdownlist is just not suitable.
> 
> What is was:  
> In the olden days(I guess I belong there?), there would be a popup  
> that shows CustomerCode and CustomerName and there would be 2 text  
> fields above for the user to put in a few characters (with wildcard).  
> Upon typing “hosp” (or “%hosp%” or “_hosp_”) and pressing “find”, the  
> selection list would filter the data and show only those filtered  
> records. User then chooses 1 from the much shorter list and it  
> returns to the previous window, populating the other fields.
> 
> Question:  
> How do I do the equivalent of this in Rails?  
> It doesn’t have to be a popup or have a text field for filtering data  
> or any of the traditional UI practices.  
> It just has to give the user an easy way to select 1 from 1,000  
> records very quickly.
> 
> Thanks.

Sounds like a simple database query, and you can tack on the ‘%’  
yourself to make it a bit more inclusive…  
You can also take a look at this:  
[http://javathehutt.blogspot.com/2009\_06\_01\_archive.html](http://javathehutt.blogspot.com/2009_06_01_archive.html)  
Absolutely awesome rails plugin for sortable tables, and it has a search  
box.

---

<div class="post-metadata">

**Author:** ![Jesterz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a4c791/32.png) [@Jesterz](https://www.ruby-forum.com/u/Jesterz)\
**Post date:** [November 5, 2009, 3:20am UTC](https://www.ruby-forum.com/t/filtering-of-rows-during-selection/178445/3 "2009-11-05T03:20:10Z")

</div>

Hi Aldric,  
Thanks for the tip.  
Could you also help guide me on how to make something like this  
sortable\_table work as a selection box that returns a selected  
customer to the Purchase Order screen?

The scenario is that the user is in a Purchase Order screen, creating  
a purchase order and is going to select a customer (out of 1000) and  
after selecting, will continue entering the other data related to the  
purchase order.

Thanks.
