Nevin Nevin - 1 month ago 8
HTML Question

Column sorting to include entire content in display table

I am using

sortable="true"
for column level sorting of display table with pagination, but when I click on header it is sorting only the current page contents. When I go to the next page the content remains as before without any sorting. Is there a way to sort the entire content of display table when column header is clicked? Below is the code to display my display table.

<display:table class="displayTable" id="person" name="persons" requestURI="personDetails" export="true" pagesize="10" requestURIcontext="false">
<display:column style="width: 30%; border: 1px solid #000;" title="Date" sortable="true">
<fmt:formatDate pattern="dd/MM/yyyy HH:mm:ss" value="${person.reportDate}" />
</display:column>
<display:column style="width: 30%; border: 1px solid #000;" property="personName" title="Name" sortable="true"/>
<display:column style="width: 30%; border: 1px solid #000;" property="personAge" title="Age" sortable="true"/>
</display:table>

Answer

I have the solution. Add sort="list" attribute in display:table tag to include the entire list in sorting, if not only current page which is displayed will be sorted.

<display:table sort="list" class="displayTable" id="person" name="persons" requestURI="personDetails" export="true" pagesize="10" requestURIcontext="false" >
    <display:column style="width: 30%; border: 1px solid #000;" title="Date" sortable="true">
            <fmt:formatDate pattern="dd/MM/yyyy HH:mm:ss" value="${person.reportDate}" />
    </display:column>
    <display:column style="width: 30%; border: 1px solid #000;" property="personName" title="Name" sortable="true"/>
    <display:column style="width: 30%; border: 1px solid #000;" property="personAge" title="Age" sortable="true"/>
</display:table>
Comments