Hello,

You can add a hidden column and sort this column and also add a column
containing the values to be displayed.
So you will have something like:
<display:table id="document" name="pageScope.listeDocuments" defaultsort="1"
class="dataTable" decorator="MyDecoratorClass">
        <display:column property="dataHidden" title="" class="hidden"
headerClass="hidden" media="html"/>
        <display:column property="dataDisplayed" title="My Data" />
</display:table>

Then you can use the MyDecoratorClass to handle this with two methods:

import org.displaytag.decorator.TableDecorator;

public class MyDecoratorClass extends TableDecorator {

        public MyDecoratorClass() {
                super();
        }

        // This method is useless
        public String getDataHidden() {
                MyObject doc = (MyObject) getCurrentRowObject();
                return doc.getDataHidden();
        }

        public String getDataDisplayed () {
                MyObject doc = (MyObject) getCurrentRowObject();
                String newFormat = "";
                // Your code here
                return newFormat;
        }
}

Hope this helps
David.

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:displaytag-
> [EMAIL PROTECTED] On Behalf Of Chris Pratt
> Sent: mercredi 23 janvier 2008 05:37
> To: DisplayTag User Group
> Subject: [displaytag-user] Sorting the Data, not the Display
> 
> Is it possible to sort by the data in the column, not by what's
> displayed on the screen?  Here's my dilemma, I have a table that shows
> mail messages and uses a friendly format for dates (If the date is
> today, it shows the time the message was received, if it was this year
> it shows the Abbreviated Month and Day, Otherwise it shows it in a
> simple 01/01/2001 format.  To achieve this little bit of magic, I just
> use a simple JSP EL Function, so my column looks like:
> 
> <display:column
> ...>${a:friendlyDate(message.receivedDate)}</display:column>
> 
> If I put the sortable="true" in there it sorts on the data displayed,
> which isn't very useful.
> 
> If I put the property="receivedDate" it ignores the formatted display
> in the body.
> 
> I was hoping I could do something like:
> 
> <display:column sortable="true"
> property="receivedDate">${a:friendlyDate(message.receivedDate)}</display:c
> olumn>
> 
> And it would use the defined property internally (for sorting and
> such) and display the body of the tag, but that doesn't seem to be the
> case.  Is there any way to make this happen?  Thanks.
>   (*Chris*)
> 
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> displaytag-user mailing list
> displaytag-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/displaytag-user


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
displaytag-user mailing list
displaytag-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/displaytag-user

Reply via email to