Tuesday, 31 May 2016

Reseting the table sort

Generally we can do sort on tables asc/desc order. Some times we need to reset the table. In that case use below code


  1. public void resetTableSort(RichTable tableComponent, String iteratorName)  
  2.   {  
  3.     BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();  
  4.     DCIteratorBinding iter = (DCIteratorBinding) bindings.get(iteratorName);  
  5.     tableComponent.queueEvent(new SortEvent(tableComponent, new ArrayList<SortCriterion>()));  
  6.     Key currentRow = null;  
  7.     Row row = iter.getCurrentRow();  
  8.     if (row != null)  
  9.     {  
  10.       currentRow = row.getKey();  
  11.     }  
  12.     SortCriteria[] sc = new SortCriteria[0];  
  13.     iter.applySortCriteria(sc);  
  14.     iter.executeQuery();  
  15.     if (currentRow != null)  
  16.     {  
  17.       iter.setCurrentRowWithKey(currentRow.toStringFormat(true));  
  18.     }  
  19.   }    


No comments:

Post a Comment