org.zkoss.zul
Interface TreeModelExt<Node>

All Known Implementing Classes:
DefaultTreeModel

public interface TreeModelExt<Node>

An extra interface that can be implemented with TreeModel to control the sorting of the data model.

Since:
5.0.6
Author:
jimmy

Method Summary
 void sort(Comparator<Node> cmpr, boolean ascending)
          It called when TreeModel or Tree has to sort the content.
 

Method Detail

sort

void sort(Comparator<Node> cmpr,
          boolean ascending)
It called when TreeModel or Tree has to sort the content.

After sorting, this model shall notify the instances of TreeDataListener (registered thru AbstractTreeModel.addTreeDataListener(org.zkoss.zul.event.TreeDataListener)) to update the content. Typically you have to notify with

new TreeDataEvent(this, TreeDataEvent.CONTENTS_CHANGED, parent, -1, -1)
to denote all data are changed (and reloading is required).

The comparator assigned to, say, Treecol.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 to Treecol.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.


Copyright © 2011. All Rights Reserved.