How to sort rows by a column through code?

View: New views
5 Messages — Rating Filter:   Alert me  

How to sort rows by a column through code?

by kaprasi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all,

I am supposed to add some more to the existing code that makes use of GL and JXTable.
I must say they are like, made for each other.

When user double clicks on a column-header the rows in the table get sorted in ascending / descending order. And when user (single) clicks on a column header the rows of that column are sorted.
Everything works just great.

Now, all I need to do is sort the rows in the table by first column (as the primary sort) and then by the second column (as the secondary sort) through code before user gets to see the table. (Default sorting to serve the user better..)

So I believe I have to use some sort keys or something like this :
http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#sorting ?
I also searched nabble for some solutions and stumbled upon the following thread :
http://www.nabble.com/EventListJXTableSorting-td11801610.html#a23574421

I was hoping this would be straight forward and easy.. But haven't found a solution yet..
I'd really appreciate if someone could provide me with some hints / solution or point me to the right direction.

Thanks.

Re: How to sort rows by a column through code?

by kaprasi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Any replies please...
All I want to do is sort the jxtable by a particular column through code before user gets to see the table.

Anticipating some response.
Thanks.

re[2]: How to sort rows by a column through code?

by Kevin Day-7 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
This should get you started:
 
 
 
Be sure to understand that the sorting GL occurs in the list pipeline itself - not in the table model.
 
There are some specifics about using GL with JXTable (I don't have them handy, but you might want to search the GL site or listserv archives for 'JXTable' and see what you find).
 
- K
 
----------------------- Original Message -----------------------
  
From: kaprasi kaprasannagt@...
Cc: 
Date: Thu, 17 Sep 2009 03:28:34 -0700 (PDT)
Subject: Re: How to sort rows by a column through code?
  

Any replies please...
All I want to do is sort the jxtable by a particular column through code
before user gets to see the table.

Anticipating some response.
Thanks.
--
View this message in context: http://www.nabble.com/How-to-sort-rows-by-a-column-through-code--tp25454154p25488718.html
Sent from the GlazedLists - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


--------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@...

Re: re[2]: How to sort rows by a column through code?

by kaprasi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks for the help but I had gone through the GL tutorial long before I posted the thread.
It hadn't helped me a bit.

Now, I believe I have kind of found a solution for now by providing a comparator which uses values in 1st column. And by commenting out the following line :
//ca.odell.glazedlists.swing.EventListJXTableSorting.install(jXTable1,sortedList);

I am just hoping this won't break something else.
If at all there are any developments in this regard I expect someone will write a line or two about it here.

Thanks.
Kevin Day wrote:





This should get you started:
 
http://sites.google.com/site/glazedlists/documentation/tutorial 
 
 
Be sure to understand that the sorting GL occurs in the list pipeline itself - not in the table model.
 
There are some specifics about using GL with JXTable (I don't have them handy, but you might want to search the GL site or listserv archives for 'JXTable' and see what you find).
 
- K
 

----------------------- Original Message -----------------------
  
From: kaprasi <kaprasannagt@gmail.com>
To:  users@glazedlists.dev.java.net
Cc: 
Date: Thu, 17 Sep 2009 03:28:34 -0700 (PDT)
Subject: Re: How to sort rows by a column through code?
  
Any replies please... All I want to do is sort the jxtable by a particular column through code before user gets to see the table. Anticipating some response. Thanks. -- View this message in context: http://www.nabble.com/How-to-sort-rows-by-a-column-through-code--tp25454154p25488718.html Sent from the GlazedLists - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@glazedlists.dev.java.net For additional commands, e-mail: users-help@glazedlists.dev.java.net


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glazedlists.dev.java.net
For additional commands, e-mail: users-help@glazedlists.dev.java.net

Parent Message unknown Re: re[2]: How to sort rows by a column through code?

by Holger Brands :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

there are basically two ways to integrate Glazed Lists sorting with JXTable
as outlined here;
http://sites.google.com/site/glazedlists/documentation/swingx

1.) using EventListJXTableSorting

with this approach, you could set your initial comparator on the SortedList.
But this doesn't work because of bug
https://glazedlists.dev.java.net/issues/show_bug.cgi?id=479
You could try the latest build, which has an additional install-method
EventListJXTableSorting#install(JXTable, SortedList, Comparator)
which allows to pass in the initial comparator to use.

2.) using TableComparatorChooser

with this approach, you have the option to set the comparator via
AbstractTableComparatorChooser.appendComparator(...)

If you use multi-column sort, you may have to call
AbstractTableComparatorChooser.clearComparator() first,
to clear other comparators.

Hope this helps,
Holger

>
> Thanks for the help but I had gone through the GL tutorial long before I
> posted the thread.
> It hadn't helped me a bit.
>
> Now, I believe I have kind of found a solution for now by providing a
> comparator which uses values in 1st column. And by commenting out the
> following line :
> //ca.odell.glazedlists.swing.EventListJXTableSorting.install(jXTable1,sortedList);
>
> I am just hoping this won't break something else.
> If at all there are any developments in this regard I expect someone will
> write a line or two about it here.
>
> Thanks.
>
> Kevin Day wrote:
> >
> >
> >
> >
> >
> >
> >
> > This should get you started:
> >  
> > http://sites.google.com/site/glazedlists/documentation/tutorial 
> >  
> >  
> > Be sure to understand that the sorting GL occurs in the list pipeline
> > itself - not in the table model.
> >  
> > There are some specifics about using GL with JXTable (I don't have them
> > handy, but you might want to search the GL site or listserv archives for
> > 'JXTable' and see what you find).
> >  
> > - K
> >  
> >
> > ----------------------- Original Message -----------------------
> >   
> > From: kaprasi <kaprasannagt@...>
> > To:  users@...
> > Cc: 
> > Date: Thu, 17 Sep 2009 03:28:34 -0700 (PDT)
> > Subject: Re: How to sort rows by a column through code?
> >   
> > Any replies please... All I want to do is sort the jxtable by a particular
> > column through code before user gets to see the table. Anticipating some
> > response. Thanks. -- View this message in context:
> > http://www.nabble.com/How-to-sort-rows-by-a-column-through-code--tp25454154p25488718.html
> > Sent from the GlazedLists - User mailing list archive at Nabble.com.
> > --------------------------------------------------------------------- To
> > unsubscribe, e-mail: users-unsubscribe@... For
> > additional commands, e-mail: users-help@...
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@...
> > For additional commands, e-mail: users-help@...
> >
> >
> >
>
> --
> View this message in context: http://www.nabble.com/How-to-sort-rows-by-a-column-through-code--tp25454154p25505743.html
> Sent from the GlazedLists - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>
>


________________________________________________________________
Neu: WEB.DE Doppel-FLAT mit Internet-Flatrate + Telefon-Flatrate
für nur 19,99 Euro/mtl.!* http://produkte.web.de/go/02/


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...