tags:

views:

66

answers:

1

I have a table showing a list of objects; let's call them Employee for clarity's sake.

The table shows Employee objects that are child objects of a given parent object which is also an Employee. What I would like to do is show a special header row with the parent object, either above (if possible) or below the normal column heading, but in a different color. I want the columns of the parent object row to be resized in sync with the rest of the table, and I don't want the parent object to be selectible.

(Basically I want to show a self-contained table of child objects, along with a separate parent "context" which has the same fields.)

Is there a good way to do this? (one table with a special row? two tables, where the one for the parent context object is only 1 row vertical, and horizonally resizes to match the other?)

+3  A: 

I think you should make the special row always be rendered at row 0 in the table, using whatever renderer you need to change the color etc. That way you get the resizing for free.

In order to make this row unselectable, I think you'll need to override the createDefautSelectionModel method to your own implementation of ListSelectionModel. You can probably override the DefaultListSelectionModel to ignore a value of 0 (first row) in the setAnchorSelectionIndex method and setLeadSelectionIndex methods.

Should work, but haven't tested.

I82Much
thanks, I bailed on the non-selectable, but otherwise it works. (I've been using GlazedLists and finally figured out that CompositeList allows you to merge two lists in sequence, so I made a CompositeList with the first list including my "special" row.
Jason S
I've seen a lot of good things about GlazedLists - I'll have to check it out. Glad you have everything working
I82Much