Thursday, June 14, 2012

Liferay Search Container : Orderable Columns

In this post we are going to implement the orderable columns for search container.

Following are the steps -

1. Put the following code in your jsp which is used to render the search container.


This If condition is provided to handle the default case. Here defaultColumn and defaultOrder can be replaced with the desired column and order respectively. Here we are sorting the results on the title column.

2.  Here is the TitleComparator.java code -



3.  add the following code to your controller's render method :



4.  Here is the search container part -




Now Title column in the search container will be rendered as clickable and upon clicking will sort the title column data.

3 comments:

  1. Hmmm.... so if I set

    orderableProperty=“title” in

    <liferay-ui:search-container-column-text name=“Title”

    value=”” orderable=“true” orderableProperty=“title” />

    it's available from orderByCol = (String)request.getAttribute(“title”);

    , didn't try it myself. just thinking..

    ReplyDelete
  2. It will be available from

    orderByCol = (String)request.getAttribute(“orderByCol”);

    ReplyDelete
  3. Hi,

    I wanted to make header clickable , so that i can give user dynamic sorting . Even after using your snippets , i was unable to make it work . Can you send me working code solution for this on sand.mayur@gmail.com

    Thanks in advance

    ReplyDelete