DisplayTag
  1. DisplayTag
  2. DISPL-501

Column sorting is broken with a decorator

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.1.1
    • Fix Version/s: 1.1.1
    • Component/s: Paging/Sorting
    • Labels:
      None
    • Application server:
      Tomcat 5.5

      Description

      I created a column called "Document Title". I created a Table Decorator so I could wrap a URL around the data (since the current linking implementation does not support target="" in the hyperlink).

      Example Decorator:

      public String getDocumentTitle() {
      Row currentRow = (Row)getCurrentRowObject();
      String pidString = currentRow.getPidString();
      String documentTitle = currentRow.getDocumentTitle();
      return "<a href=\"/BPView/docOpener.jsp?pid=" + pidString + "\" target=\"_blank\" class=\"doclinks\"><nobr>" + documentTitle + "</nobr></a>";
      }

      After doing this, the column no longer sorted on the data that was in my "documentTitle" property, instead it sorted on the TEXT that was put into the documentTitle after the decorator had been applied - so effectively I was sorting on "pidString" instead.

      Note that in the current URL linking mechanism, applying a URL does not alter the Sorting. It still sorts on the data from the column instead of the URL that was wrapped around the hyperlink.

      Similarly, adding a decoration to a column should not have an effect on the sort. Perhaps there could be an optional parameter sortOnDecoratedColumn or something which would allow you to specify to sort on the actual data or the "decorated data" for the column.

        Activity

        Hide
        Kevin Conaway added a comment -
        Set the sortProperty attribute on the column to be the undecorated value.

        If that solves your problem, please close this issue
        Show
        Kevin Conaway added a comment - Set the sortProperty attribute on the column to be the undecorated value. If that solves your problem, please close this issue
        Hide
        allan flatoff added a comment -
        I altered the decorator to use a different name from the property:

        public String getDocumentTitleWithLink() {
        Row currentRow = (Row)getCurrentRowObject();
        String pidString = currentRow.getPidString();
        String documentTitle = currentRow.getDocumentTitle();
        return "<a href=\"/BPView/docOpener.jsp?pid=" + pidString + "\" target=\"_blank\" class=\"doclinks\"><nobr>" + documentTitle + "</nobr></a>";
        }

        **

        I then set the table to display the altered property but sort on the real one:

        <display:column property="documentTitleWithLink" title="Doc Title" sortable="true" sortProperty="documentTitle" headerClass="sortable"/>

        This worked. Much cleaner than a javascript hack I threw together.

        Thanks!
        Show
        allan flatoff added a comment - I altered the decorator to use a different name from the property: public String getDocumentTitleWithLink() { Row currentRow = (Row)getCurrentRowObject(); String pidString = currentRow.getPidString(); String documentTitle = currentRow.getDocumentTitle(); return "<a href=\"/BPView/docOpener.jsp?pid=" + pidString + "\" target=\"_blank\" class=\"doclinks\"><nobr>" + documentTitle + "</nobr></a>"; } ** I then set the table to display the altered property but sort on the real one: <display:column property="documentTitleWithLink" title="Doc Title" sortable="true" sortProperty="documentTitle" headerClass="sortable"/> This worked. Much cleaner than a javascript hack I threw together. Thanks!
        Hide
        allan flatoff added a comment -
        There is a workaround - posted in comments
        Show
        allan flatoff added a comment - There is a workaround - posted in comments
        Hide
        Kevin Conaway added a comment -
        You don't even need a decorator for it:

        <display:table ... uid="row">
          

          <display:column title="Doc Title" sortable="true" sortProperty="documentTitle" headerClass="sortable">
            <a href="/BPView/docOpener.jsp?pid=${row.pidString}" target="_blank" class="doclinks"><nobr>${row.documentTitle}</nobr></a>
          <display:column>

        </display:table>

        Thats if you're using the newer servlet versions. Otherwise, you can put <c:out/> tags in for the inline expressions
        Show
        Kevin Conaway added a comment - You don't even need a decorator for it: <display:table ... uid="row">      <display:column title="Doc Title" sortable="true" sortProperty="documentTitle" headerClass="sortable">     <a href="/BPView/docOpener.jsp?pid=${row.pidString}" target="_blank" class="doclinks"><nobr>${row.documentTitle}</nobr></a>   <display:column> </display:table> Thats if you're using the newer servlet versions. Otherwise, you can put <c:out/> tags in for the inline expressions

          People

          • Reporter:
            allan flatoff
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: