Late last week I posted a question about filtering TableView
components and was pointed in the direction of using a filtered list.
So, I did some more thinking, and decided to build a new component
similar to the TableViewHeader.

Basically, I wanted a component that I could put above the
TableViewHeader, that would present me with a list of the columns in
the table and a textbox to enter the string to filter by.

So I built a TableViewFilter (which might not be the best name) by:

1.  Extending the BoxPane class.
2.  Adding a ListView (to select the desired column to filter) and
TextInput (to enter the filter itself) to the BoxPane.
3.  Adding a "tableView" property to my new component ala the
TableViewHeader (so in the WTKX you can instantiate the new component
and pass it a tableView just like with the header).
4.  When the setTableView is called, I populate the aforementioned
ListView with the HeaderData of each column in the TableView.
5.  Wiring up a textInputKeyListener on the TextInput that applies (or
clears) a filter on the underlying FilteredList on every character
added or removed (I had a "go" button, but decided the key listener
was slicker).
6.  For now, the filter just compares the toString method of the
Object in the selected column with the text in the TextInput.

Anyway, after much trial and error, it works.  I have a few questions though:

1.  Does anyone have a cleaner or easier way to implement the above?
2.  I'm not sure my code is contribution quality, but it might help
someone, somewhere.  Where would be a good place to put it for other
to see and laugh at?

As a follow on, I also need the ability to "Page" my table views (in
other words, get them back from the server and display them in smaller
chunks).  So I think I want to write a TableViewPaginator that works
like the header, but instead resides in the footer.  Does anyone have
any general ideas on the best way to tackle this?

Reply via email to