How to use the alphabetical sorting in <af:table> on top of procesSort()
My Application has an af:table and it has a psuedo-column named serverName along with other columns. (By psuedo-column, i mean - it is just a UI column, it doesn't have a corresponding DB column).
For sorting, we have overriden processSort(sortColumn, sortOrder) method of SortListener.
It works like this: 1) takes in sortColumn and queries the DB 2) using orderBy clause 3) fetches the results and then displays on UI
Now in my case, since my column (serverName) has no corresponding DB column, I want to surpass this method and use the default alphabetical sorting o开发者_高级运维f ADF. How do i do that?
I tried returning from this method if sortColum matches serverName, but that ends up in not sorting anything.
Use the setSortBy()
method.
Read this section in the Fusion Developers Guide.
39.5.2 Sorting View Object Rows In Memory
To sort the rows in a view object at runtime, use the setSortBy()
method. You pass a sort expression that looks like a SQL ORDER BY
clause. However, instead of referencing the column names of the table, you use the view object's attribute names. For example, for a view object containing attributes named Customer and DaysOpen, you could sort the view object first by Customer descending, then by DaysOpen by calling:
setSortBy("Customer desc, DaysOpen");
Alternatively, you can use the zero-based attribute index position in the sorting clause like this:
setSortBy("3 desc, 2");
After calling the setSortBy()
method, the rows will be sorted the next time you call the executeQuery()
method.
精彩评论