Interface GroupsSortableModel<D>
-
- All Superinterfaces:
Sortable<D>
- All Known Implementing Classes:
GroupsModelArray
,SimpleGroupsModel
public interface GroupsSortableModel<D> extends Sortable<D>
An extra interface that can be implemented withGroupsModel
to control the sorting and grouping of the data model.D: the type of the data.
- Since:
- 6.0.0
- Author:
- tomyeh
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default java.lang.String
getSortDirection(java.util.Comparator<D> cmpr)
Returns the sort direction of this model for the given comparator.void
group(java.util.Comparator<D> cmpr, boolean ascending, int colIndex)
Groups and sorts the data by the specified column.default void
sort(java.util.Comparator<D> cmpr, boolean ascending)
It called when the associated component (such asListbox
) has to sort the content.void
sort(java.util.Comparator<D> cmpr, boolean ascending, int colIndex)
-
-
-
Method Detail
-
sort
void sort(java.util.Comparator<D> cmpr, boolean ascending, int colIndex)
It called whenListbox
orGrid
has to sort the content.After sorting, this model shall notify the instances of
ListDataListener
(registered thruListModel.addListDataListener(org.zkoss.zul.event.ListDataListener)
) to update the content. Typically you have to notify with
to denote all data are changed (and reloading is required).new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, -1, -1)
The comparator assigned to, say,
Listheader.setSortAscending(java.util.Comparator)
is passed to method as the cmpr argument. Thus, developers could use it as a tag to know which column or what kind of order to sort. Notice that the comparator is capable to sort under the order specified in the ascending parameter. In other words, you could ignore the ascending parameter (which is used only for providing additional information)- Parameters:
cmpr
- the comparator assigned toListheader.setSortAscending(java.util.Comparator)
and other relative methods. If developers didn't assign any one, the default comparator is used. Notice that it is capable to sort the data in the correct order, you could ignore the ascending parameter.ascending
- whether to sort in the ascending order (or in the descending order, if false). Notice that it is used only to provide additional information. To sort the data correctly, you could count on the cmpr parameter only.colIndex
- the index of the column
-
sort
default void sort(java.util.Comparator<D> cmpr, boolean ascending)
Description copied from interface:Sortable
It called when the associated component (such asListbox
) has to sort the content.After sorting, this model shall notify the component abort the result. For example, if this interface is used with
ListModel
, then it might do the following to notify all registered listenersListDataListener
(registered byListModel.addListDataListener(org.zkoss.zul.event.ListDataListener)
) to update the content:new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, -1, -1)
The comparator assigned to, say,
Listheader.setSortAscending(java.util.Comparator)
is passed to method as the cmpr argument. Thus, developers could use it as a tag to know which column or what kind of order to sort. Notice that the comparator is capable to sort under the order specified in the ascending parameter. In other words, you could ignore the ascending parameter (which is used only for providing additional information)- Specified by:
sort
in interfaceSortable<D>
- Parameters:
cmpr
- the comparator assigned toListheader.setSortAscending(java.util.Comparator)
and other relative methods. If developers didn't assign any one, the default comparator is used. Notice that it is capable to sort the data in the correct order, you could ignore the ascending parameter.ascending
- whether to sort in the ascending order (or in the descending order, if false). Notice that it is used only to provide additional information. To sort the data correctly, you could count on the cmpr parameter only.
-
getSortDirection
default java.lang.String getSortDirection(java.util.Comparator<D> cmpr)
Description copied from interface:Sortable
Returns the sort direction of this model for the given comparator. It must be one of "ascending", "descending" and "natural".Default: "natural".
- Specified by:
getSortDirection
in interfaceSortable<D>
-
group
void group(java.util.Comparator<D> cmpr, boolean ascending, int colIndex)
Groups and sorts the data by the specified column. It only called whenListbox
orGrid
has the sort function.- Parameters:
cmpr
- the comparator assigned toColumn.setSortAscending(java.util.Comparator<?>)
and other relative methods. If developers didn't assign any one, the method is returned directly.ascending
- whether to sort in the ascending order (or in the descending order)colIndex
- the index of the column
-
-