Added orderable=true to Liferay search container, controls appeared but order does not change
Asked Answered
G

1

10

I have written a Liferay search container, it works great.
Now I want columns to be sortable by alphabetical order, so I added orderable="true":

<liferay-ui:search-container
    <liferay-ui:search-container-results
        results="<%= BicycleLocalServiceUtil.getBicyclesByCompanyId(
                                         themeDisplay.getCompanyId()) %>"
        total="<%= BicyleLocalServiceUtil.getBicyclesCount() %>" />

    <liferay-ui:search-container-row
        className="com.example.portal.portlet.navigation.model.Bicycle"
        keyProperty="bicycleId"
        modelVar="bicycle"
        escapedModel="<%= true %>">

        <liferay-ui:search-container-column-text
            name="name"
            property="name"
            value="<%= bicycle.getName() %>"
            orderable="<%= true %>"
        />

        <liferay-ui:search-container-column-text
            name="nickname"
            property="nickname"
            orderable="<%= true %>"
        />

        <liferay-ui:search-container-column-jsp
            align="right"
            path="/html/bicycle/bicycle_actions.jsp" />
    </liferay-ui:search-container-row>

    <liferay-ui:search-iterator />
</liferay-ui:search-container>

The results looks good:Liferay orderable but when I click on the name or any of the small arrows, the order of the rows below does not change.

Am I missing something?
I don't need any custom comparator as the value are simple Strings such as "Bob" and "Joe".

Gambrell answered 26/1, 2016 at 9:9 Comment(2)
Did you try orderable="<%= true %>"? And sometimes you need to set the property (property="...") that is used for ordering.Duramen
@TobiasLiefke: Yes, same problem with the "true" and the "property". I updated the code to reflect that, thanks!Gambrell
P
1

You need to specify the oderableProperty:

<liferay-ui:search-container-column-text
            name="nickname"
            property="nickname"
            orderableProperty="nickname"
            orderable="<%= true %>"
        />
Pinky answered 2/6, 2017 at 14:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.