When data needs to be sorted according to one or several attributes,
we can use Sort to represent the sorting information and generate
appropriate hyperlinks that can lead to sort actions.
// display links leading to sort actions <%- sort.link('name') + ' | ' + sort.link('age') %>
fore(letmodelofmodels) { // display model here }
In the above, we declare two attributes that support sorting: name and age.
We pass the sort information to the Post query so that the query results are
sorted by the orders specified by the Sort object. In the view, we show two hyperlinks
that can lead to pages with the data sorted by the corresponding attributes.
attributeOrders Sort directions indexed by attribute names. Sort direction can be either
SORT_ASC for ascending order or SORT_DESC for descending order. Note that the type of this property
differs in getter and setter. See getAttributeOrders and [[setAttributeOrders]] for details.
property-read
orders The columns (keys) and their corresponding sort directions (values). This can
be passed to the 'order by' clause of the DB query. This property is read-only.
Sort represents information relevant to sorting.
When data needs to be sorted according to one or several attributes, we can use Sort to represent the sorting information and generate appropriate hyperlinks that can lead to sort actions.
A typical usage example is as follows,
View:
In the above, we declare two attributes that support sorting:
name
andage
. We pass the sort information to the Post query so that the query results are sorted by the orders specified by the Sort object. In the view, we show two hyperlinks that can lead to pages with the data sorted by the corresponding attributes.For more details and usage information on Sort, see the guide article on sorting.
attributeOrders Sort directions indexed by attribute names. Sort direction can be either
SORT_ASC
for ascending order orSORT_DESC
for descending order. Note that the type of this property differs in getter and setter. See getAttributeOrders and [[setAttributeOrders]] for details.orders The columns (keys) and their corresponding sort directions (values). This can be passed to the 'order by' clause of the DB query. This property is read-only.
Mahesh S Warrier https://github.com/codespede