column order

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

column order

Brian Dusenberry
Hello,

We currently used glazed list tables within our application, and have had several requests to be able to persist table preferences per user..  such as column order, column width, sorting preference, etc.

Is there a way within the glazed list API to be able to do this, or what would be involved?

thanks, Brian
Reply | Threaded
Open this post in threaded view
|

Re: column order

Rob Eden
Hi Brian -

GlazedLists wouldn't really be involved with column order or width. You would save the table view order as opposed to saving anything relating to the model (which is what GL is involved with). So, you'll want to work with the JTable (or JXTable if you're using SwingX) API relating to the view parameters.

Now, depending on how you're doing your sorting, the GL API may or may not be involved. I'd need a bit more info on how you have that implemented. If you're using built-in SwingX functionality, for example, then you would just work with those API's. If you're using GL functionality, then you may need to make some GL-API-related changes.

Rob


On Mon, Apr 7, 2014 at 9:39 AM, Brian Dusenberry <[hidden email]> wrote:
Hello,

We currently used glazed list tables within our application, and have had several requests to be able to persist table preferences per user..  such as column order, column width, sorting preference, etc.

Is there a way within the glazed list API to be able to do this, or what would be involved?

thanks, Brian

Reply | Threaded
Open this post in threaded view
|

Re: column order

James Lemieux
In reply to this post by Brian Dusenberry
Hi Brian,

   Column order and Column width will be your responsibilities since Glazed Lists doesn't play directly in that space, although it's not very hard. The typical way to accomplish this is to assign a unique column identifier to your TableColumn objects. With that in place, you can easily create a CSV string that represents the identifiers of the visible columns reported by the TableColumnModel at any moment in time. A similar approach for column widths should work just fine.

   What GlazedLists can help you with is restoring the sort order, assuming you're using TableComparatorChooser. You can call toString() on your TCC to get an encoded string that describes which columns, in which order and in which direction are currently participating in your table sort. Stash that string wherever you put your preferences. Later, when restoring the table's state from preferences, simply call fromString(String) on TableComparatorChooser after restoring up your TableColumnModel state.

James 

    


On Mon, Apr 7, 2014 at 7:39 AM, Brian Dusenberry <[hidden email]> wrote:
Hello,

We currently used glazed list tables within our application, and have had several requests to be able to persist table preferences per user..  such as column order, column width, sorting preference, etc.

Is there a way within the glazed list API to be able to do this, or what would be involved?

thanks, Brian

Reply | Threaded
Open this post in threaded view
|

Re: column order

Gerrit Cap
In reply to this post by Brian Dusenberry
Hi Brian,

I suppose the Glazed Lists "owners" will correct me if I am wrong, but I don't think Glazed Lists supports this.

But, it is quite easy to do so. Of course it depends on what framework you are using: Swing, SwingX, ...

If you are using Swing then you are thus using a JTable, each JTable object allows you to query for the column model via the getColumnModel method, it is a container for TableColumn objects which have getWidth and setWidth methods.

Futhermore: a JTable object also allows you to query the rowsorter via the ..(drum roll) ... getRowSorter() method, this object allows you to get & set the sortkeys

and of course your table model allows you to specify which are the columns being shown and in which order.

This is "pure" swing stuff.

If you put Glazed Lists behind a JTable, then of course you must be using an DefaultEventTableModel which specifies the columns being shown and their order.

And to apply sorting on a JTable with GlazedLists, you "install" a TableComparatorChooser on a JTable backed by a SortedList, the table comparator chooser has a toString() method which represents the current sort order as a string which can be re-parsed via the fromString method.

If you are using SwingX, I can send you some working code I have used in a project myself.

Regards,

Gerrit

-- 
-------------------- Marble Consulting ----------------------
Gerrit Cap                      http://www.marble.be/
Software Engineer               [hidden email]
Marble Consulting               gsm : +32 475 72.94.36
Vinkenbosstraat 13              tel : +32 16 89.50.55
B-3001 Leuven			fax : +32 16 89.50.58         
On 7/04/2014 16:39, Brian Dusenberry wrote:
Hello,

We currently used glazed list tables within our application, and have had several requests to be able to persist table preferences per user..  such as column order, column width, sorting preference, etc.

Is there a way within the glazed list API to be able to do this, or what would be involved?

thanks, Brian

Reply | Threaded
Open this post in threaded view
|

Re: column order

James Lemieux
Just a small correction to Gerrit's post:

You won't want to read information about columns from the TableModel. Those represent the columns known to the data layer (i.e. the domain of columns that could be potentially displayed). The TableColumnModel models which columns are ACTUALLY VISIBLE.

For example, it is quite possible and indeed desirable to implement toggling column visibility (by adding and removing it to the TableColumnModel) and not disturbing your TableModel at all. As such, your TableModel could easily define, say, 20 total columns, of which only 7 are currently visible (i.e. returned from the TableColumnModel).

James


On Mon, Apr 7, 2014 at 11:31 AM, Gerrit Cap <[hidden email]> wrote:
Hi Brian,

I suppose the Glazed Lists "owners" will correct me if I am wrong, but I don't think Glazed Lists supports this.

But, it is quite easy to do so. Of course it depends on what framework you are using: Swing, SwingX, ...

If you are using Swing then you are thus using a JTable, each JTable object allows you to query for the column model via the getColumnModel method, it is a container for TableColumn objects which have getWidth and setWidth methods.

Futhermore: a JTable object also allows you to query the rowsorter via the ..(drum roll) ... getRowSorter() method, this object allows you to get & set the sortkeys

and of course your table model allows you to specify which are the columns being shown and in which order.

This is "pure" swing stuff.

If you put Glazed Lists behind a JTable, then of course you must be using an DefaultEventTableModel which specifies the columns being shown and their order.

And to apply sorting on a JTable with GlazedLists, you "install" a TableComparatorChooser on a JTable backed by a SortedList, the table comparator chooser has a toString() method which represents the current sort order as a string which can be re-parsed via the fromString method.

If you are using SwingX, I can send you some working code I have used in a project myself.

Regards,

Gerrit

-- 
-------------------- Marble Consulting ----------------------
Gerrit Cap                      http://www.marble.be/
Software Engineer               [hidden email]
Marble Consulting               gsm : <a href="tel:%2B32%20475%2072.94.36" value="+32475729436" target="_blank">+32 475 72.94.36
Vinkenbosstraat 13              tel : <a href="tel:%2B32%2016%2089.50.55" value="+3216895055" target="_blank">+32 16 89.50.55
B-3001 Leuven			fax : <a href="tel:%2B32%2016%2089.50.58" value="+3216895058" target="_blank">+32 16 89.50.58         
On 7/04/2014 16:39, Brian Dusenberry wrote:
Hello,

We currently used glazed list tables within our application, and have had several requests to be able to persist table preferences per user..  such as column order, column width, sorting preference, etc.

Is there a way within the glazed list API to be able to do this, or what would be involved?

thanks, Brian