Menu

Sort order descending with external sorting

Help
2007-01-28
2012-10-09
  • downunder_al

    downunder_al - 2007-01-28

    Hi

    I have successfully got the paging and sorting thing going, so long as I only want to sort ascending. The column header link, which I assume should toggle to allow descending sorting, only ever allows ascending:
    foo/MasterTransactionList.do?sort=created&dir=asc

    I am using the following code:

    <display:table name="resultList" pagesize="50" sort="external" requestURI="MasterTransactionList.do">
    <display:column sortName="created" property="created" sortable="true" title="Created Date" />
    </display:table>

    Any suggestions?

     
    • downunder_al

      downunder_al - 2007-02-07

      Actually, I spoke too soon. All that was happening was that the defaultSortOrder was being set. When that happened, it was possible to sort the default column both asc and desc. However, it was impossible to sort any other columns.

      I have re-read the documentation (several times) and I think I'm doing it right. Here is the current version:

      I am using the value list pattern - that is, the form for displaying in the table implements org.displaytag.pagination.PaginatedList correctly. That means that I don't need to do the sort="external" thing.

      The table:
      <display:table name="masterTransactionPagedList" defaultsort="1" id="element" requestURI="MasterTransactionList.do" decorator="com.agl.mdh.display.decorators.MasterTransactionListDecorator">
      <display:column property="market" sortable="true" title="Market" />
      </display:table>

      I have tried it with the sortName value set, but the link rendered by the sort href never seems to use it - i.e. it always looks like this:
      http://localhost:8080/portal/action/MasterTransactionList.do?transactionID=&sort=market&dir=asc (I have trimmed some of the other irrelevant parameters) Which is as the documentation suggests it should look - http://foo.bar.com/context/requestUri?sort=name&dir=asc&originalParameters=originalValues. )

      The page number links work OK: http://localhost:8080/portal/action/MasterTransactionList.do?sort=market&superTranType=B2B&dir=asc&page=2 (which again seems correct)

      It's just that the sorting never triggers - so the link from the header is always set to be dir=asc. Interestingly, the css class which is triggered when the column is sorted, is never triggered (and it was triggered when I had the defaultsort property set). The result of this is that when I click the link, the back end picks up the correct column to sort by, but the sorting href never changes to "desc".

      I am completely stumped by this. I really like the library (and really don't want to have to spend ages finding another sorting and paging library (or writing my own)), but I'm getting desperate. Is it possible that there is a bug in the library? I will have a bit of a poke around in the code and see if I can figure it out.

       
      • Fuad Efendiyev

        Fuad Efendiyev - 2007-03-13

        You should probably make value of defaultSortOrder dynamic (managed by backend)...

         
    • downunder_al

      downunder_al - 2007-02-07

      I've solved the problem, thanks to Michael (http://sourceforge.net/mailarchive/forum.php?thread_id=31549689&forum_id=28703) - the basic problem was that I wasn't flagging the partial list. The following jsp is working for me now:

      <display:table name="masterTransactionPagedList" defaultsort="1" pagesize="20" id="element" partialList="true" size="requestScope.masterTransactionPagedList.fullListSize"
      requestURI="MasterTransactionList.do" decorator="com.agl.mdh.display.decorators.MasterTransactionListDecorator">...

      where there is a method getFullListSize() method in my bean masterTransactionPagedList which returns the correct full list size.

      I thought I'd read the documentation, but,as it turns out, I hadn't. Anyway, this example may help other equally vague people.

       
    • Tinu V Thomas

      Tinu V Thomas - 2007-02-08

      Hi friend,

      I am facing the same problem that mentioned in the previous post. I am using "External pagination and sorting" feature of the display tag. For that I am using value list pattern. Pagination is working fine. I have one problem with sorting. "dir" parameter of the request url always has the value "asc". But in my application I need to sort in descending order also. Following is the url that I got. Any suggestions to get "desc" value for "dir" parameter?

      http://localhost:9080/TestDisplayTagStruts/TanWbo.do?sort=id&dir=asc

      Following is my jsp code...

      <display:table name="${TanWboBean.externalPaginationAndSortData}" defaultsort="1" cellpadding="5" cellspacing="1" requestURI="TanWbo.do">
      <display:column property="id" title="id" sortable="true" > </display:column>
      <display:column property="caseId" title="caseid" sortable="true"> </display:column>
      </display:table>

      thanks in advance
      Tinu V Thomas

       
      • Fuad Efendiyev

        Fuad Efendiyev - 2007-03-13

        don't forget to add more functionality:
        public SortOrderEnum getSortDirection() {
        // TODO: ASCENDING
        return SortOrderEnum.DESCENDING;
        }

        • see PaginatedList...
         

Log in to post a comment.