Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Sorting columns of Tree table structure

Hi ,

We have developed Tree Table structure based on the tutorial, but the data in the columns are not in the right order. Can anyone tell me how to do column sorting for Tree table structure, I know how to do column sorting on normal table structure but that logic does not work for Tree table structures

Appreciate your help


Former Member

Hi Som,

If you are using TutWD_TreeByNestingTableColumn project as example, this code can help you:

  //@@begin javadoc:onActionSortTree(ServerEvent)
  /** Declared validating event handler. */
  public void onActionSortTree( wdEvent )
    //@@begin onActionSortTree(ServerEvent)

  private void sort(IPrivateTreeTableView.ICatalogEntriesNode catalogEntriesNode) {
  	if(null==catalogEntriesNode) return;
	int size = catalogEntriesNode.size();
	for(int i=0;i<size;i++) {
		sort( catalogEntriesNode.nodeChildCatalogEntries(i) );
  private static final Comparator COMPORATOR = new CatalogEntriesComparator(); 
  private static class CatalogEntriesComparator implements Comparator {
	public int compare(Object o1, Object o2) {
		IPrivateTreeTableView.ICatalogEntriesElement ot1 = (IPrivateTreeTableView.ICatalogEntriesElement)o1;
		IPrivateTreeTableView.ICatalogEntriesElement ot2 = (IPrivateTreeTableView.ICatalogEntriesElement)o2;
		return Collator.getInstance().compare(	ot1!=null ? ot1.getTITLE() : "", 
										ot2!=null ? ot2.getTITLE() : "");
	public boolean equals(Object obj) {
		return false;

Best regards, Maksim Rashchynski.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question