|Don't ask to ask, just ask|
Introducing FilterOnClick for Perlby trs80 (Priest)
|on Oct 15, 2005 at 17:53 UTC||Need Help??|
In 2002 I posted a node entitled RFC on module idea, well nearly 4 years later I have a 1.0 version release of the concepts first discussed in that post. Introducing FilterOnClick. All the features mentioned in my original post either exist or have been improved upon under the FilterOnClick banner.
The current implementation is a Plugin for Class::DBI and is available as Class::DBI::Plugin::FilterOnClick. FilterOnClick from an abstraction standpoint owes a great deal to the Class::DBI approach to database interaction.
FilterOnClick is based on two specific techniques of interacting with data sets:
Knowledge based interaction - Interaction when you know what you are looking for. Example - You know the person wants all the items in blue with a star pattern.
Discovery based interaction - Not knowing specifically what you are looking for or perhaps looking for an anomaly. Example - You want to look for out of place data or interesting values to determine their frequency of occurrence.
The name FilterOnClick is derived from the actual interaction with the data sets via the browser. An HTML table is produced and particular values within a cell can be clicked on (if configured appropriately) to "filter" the results. If a column (database field) is configured as searchable a search can be done based on any string. It also has support for NULL and empty fields to assist with finding an anomaly. Another feature is the ability to cascade filters across multiple columns. This allows for a drill down into a specific type of item you would like. In addition to cascading they are not fixed in order so you can selectively remove or add filters at anytime in the process.
An example use of FilterOnClick would be an automobile sales web site.
We will use a database containing car information as our example dataset. In the database you have the common attributes of each vehicle; mileage, color, price, transmission type, year, make, model, etc. Using Class::DBI::Plugin::FilterOnClick you can create a CGI script and make any click on year equal a filter for an exact match look up if clicked. That would allow a user to find the year they are interested in and then filter to just that year. A variance filter offers a little power, you can use the variance and look up and down x number of years, where x is the difference.
So using a variance of 2 instead of an exact match allow the user to show all cars between 2001 - 2005 years if they clicked on 2003.
If price is added and setup as searchable + a variance you could search for all cars with an exact price (say $20,000, for example) and then with a percent variance click on any $20,000 cell value and find all cars between 2001 - 2005 priced within 5% of $20,000 since our filters cascade.
Now we add another FilterOnClick rule on mileage, here again we use a variance, this time 10% and that column is searchable as well. We type in 30000 for the search criteria which shows all vehicles with 30K (if any), we can now click on a 30K value in any cell in the price column.
With all the above filters available and applied the user will now see all 2001 - 2005 cars with 27,000 - 33,000 miles on them with a price between $19,000 and 21,000.
Now based on our available options our user decides the year restriction is too limiting, which is what we chose first, we can now click on any value in the year colum and the filter on year is remove, but the other filters remain valid. In other words we are only filtering on price and miles now.
Multiple combinations of the above can be created simply by adding a filter type on a particular column. FilterOnClick makes it easy to create unique lookups that otherwise would require custom programming to meet a particular condition that is prone to change.
Class::DBI::Plugin::FilterOnClick can also be used to connect databases that you don't have write access to. Using a connector table you can record notes based on the your discovery in the read only database back to your writable database. You can even include content from within multiple databases with a single table based on the primary key of the base table.
FilterOnClick Demo site
This module relies heavily on a number of other CPAN modules so thank you to all the contributors to CPAN for helping make my module possible.