You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Steve Lowery <sl...@gatessolutions.com> on 2013/06/14 17:42:13 UTC

DataTable sort column descending

Is there an easy way to have a DataTable column sort descending the first
time it is clicked on?  The code in OrderByLink does the following:

protected SortOrder nextSortOrder(final SortOrder order)
{
// init / flip order
if (order == SortOrder.NONE)
{
return SortOrder.ASCENDING;
}
else
{
return order == SortOrder.ASCENDING ? SortOrder.DESCENDING :
SortOrder.ASCENDING;
}
}

The first time it is NONE, so it changes to ASCENDING.  This is the desired
outcome in most use cases, but not one I am working on.  I think I can
override this, but it's ugly since I'd have to go through
OrderByLinkBorder, HeadersToolbar and to Datatable.  Just wondering if
there's a cleaner and/or easier way.

-- 
 

IMPORTANT: This e-mail (including any attachments) is intended for the use 
of the individual or entity to which it is addressed and may contain 
information that is classified, private, or confidential. If the reader of 
this message is not the intended recipient, or the employee or agent 
responsible for delivering the message to the intended recipient, you are 
hereby notified that any dissemination, distribution, or copying of this 
communication is prohibited. If you have received this communication in 
error, please notify us immediately by replying to this e-mail. Thank you.

Re: DataTable sort column descending

Posted by Paul Bors <pa...@bors.ws>.
Change your table to use an ISortableDataProvider and define your default
sort order.
http://ci.apache.org/projects/wicket/apidocs/6.x/org/apache/wicket/extensions/markup/html/repeater/data/table/ISortableDataProvider.html

~ Thank you,
   Paul Bors


On Fri, Jun 14, 2013 at 11:42 AM, Steve Lowery
<sl...@gatessolutions.com>wrote:

> Is there an easy way to have a DataTable column sort descending the first
> time it is clicked on?  The code in OrderByLink does the following:
>
> protected SortOrder nextSortOrder(final SortOrder order)
> {
> // init / flip order
> if (order == SortOrder.NONE)
> {
> return SortOrder.ASCENDING;
> }
> else
> {
> return order == SortOrder.ASCENDING ? SortOrder.DESCENDING :
> SortOrder.ASCENDING;
> }
> }
>
> The first time it is NONE, so it changes to ASCENDING.  This is the desired
> outcome in most use cases, but not one I am working on.  I think I can
> override this, but it's ugly since I'd have to go through
> OrderByLinkBorder, HeadersToolbar and to Datatable.  Just wondering if
> there's a cleaner and/or easier way.
>
> --
>
>
> IMPORTANT: This e-mail (including any attachments) is intended for the use
> of the individual or entity to which it is addressed and may contain
> information that is classified, private, or confidential. If the reader of
> this message is not the intended recipient, or the employee or agent
> responsible for delivering the message to the intended recipient, you are
> hereby notified that any dissemination, distribution, or copying of this
> communication is prohibited. If you have received this communication in
> error, please notify us immediately by replying to this e-mail. Thank you.
>