cancel
Showing results for 
Search instead for 
Did you mean: 

Sorting columns of Tree table structure

Former Member
0 Kudos

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

Som

Accepted Solutions (1)

Accepted Solutions (1)

former_member182372
Active Contributor
0 Kudos

Hi Som,

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


  //@@begin javadoc:onActionSortTree(ServerEvent)
  /** Declared validating event handler. */
  //@@end
  public void onActionSortTree(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
  {
    //@@begin onActionSortTree(ServerEvent)
	sort(wdContext.nodeCatalogEntries());
    //@@end
  }

  private void sort(IPrivateTreeTableView.ICatalogEntriesNode catalogEntriesNode) {
  	if(null==catalogEntriesNode) return;
	catalogEntriesNode.sortElements(COMPORATOR);
	
	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.

Former Member
0 Kudos

Hi Maksim,

This is just awesome man. I am very happy and wanted to give you 1000 points but you know can only give 10 points..

Thank a lot for your time, appreciated.

Best Regards

Som

Answers (1)

Answers (1)

Former Member
0 Kudos

hi Som,

Hi Gregory,

"Must read" for Tree-in-table users:

/people/valery.silaev/blog/2005/06/13/master-of-columns-part-i

/people/valery.silaev/blog/2005/06/20/master-of-columns-part-ii

Best regards, Maksim Rashchynski.

Valery Silaev

Posts: 1,549

Questions: 16

Forum Points: 3,269

Registered: 3/3/04

Re: Integration of a Tree Structure in a Web DynPro Table

Posted: Feb 15, 2006 9:33 AM Reply E-mail this post

Gregory,

1. Either in hard way, read this: /people/valery.silaev/blog/2005/06/20/master-of-columns-part-ii

2. If you have SP13+ version, then you may add source mapping for onLeadSelect action, same as for onLoadChildren in blog mentioned above, the only differens is wdDoModifyView:

if ( firstTime )

{

...

final IWDTable tblEntries = (IWDTable)view.getElement("<table-id>");

tblEntries.mappingOfOnLeadSelect().addSourceMapping

(

"nodeElement",

"<name-of-param-in-action-handler>"

);

}

Thanks,

Raj.