org.kuali.rice.krad.web.controller.helper
Class DataTablesPagingHelper

java.lang.Object
  extended by org.kuali.rice.krad.web.controller.helper.DataTablesPagingHelper

public class DataTablesPagingHelper
extends Object

Author:
Kuali Rice Team (rice.collab@kuali.org)

Nested Class Summary
static class DataTablesPagingHelper.DataTablesInputs
          Input command processor for supporting DataTables server-side processing.
 
Constructor Summary
DataTablesPagingHelper()
           
 
Method Summary
protected  void applyTableJsonSort(List<Object> modelCollection, List<ColumnSort> oldColumnSorts, List<ColumnSort> newColumnSorts, CollectionGroup collectionGroup, View view)
          Sort the given modelCollection (in place) according to the specified columnSorts.
 Integer getFilteredCollectionSize()
           
 TableLayoutManager getTableLayoutManager()
           
 int getTotalCollectionSize()
           
 void processPagingRequest(View view, String tableId, UifFormBase form, DataTablesPagingHelper.DataTablesInputs dataTablesInputs)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataTablesPagingHelper

public DataTablesPagingHelper()
Method Detail

processPagingRequest

public void processPagingRequest(View view,
                                 String tableId,
                                 UifFormBase form,
                                 DataTablesPagingHelper.DataTablesInputs dataTablesInputs)

applyTableJsonSort

protected void applyTableJsonSort(List<Object> modelCollection,
                                  List<ColumnSort> oldColumnSorts,
                                  List<ColumnSort> newColumnSorts,
                                  CollectionGroup collectionGroup,
                                  View view)
Sort the given modelCollection (in place) according to the specified columnSorts.

Not all columns will necessarily be directly mapped to the modelCollection, so the collectionGroup and view are available as well for use in calculating those other column values. However, if all the columns are in fact mapped to the elements of the modelCollection, subclasses should be able to easily override this method to provide custom sorting logic.

Create an index array and sort that. The array slots represents the slots in the modelCollection, and the values are indices to the elements in the modelCollection. At the end, we'll re-order the modelCollection so that the elements are in the collection slots that correspond to the array locations. A small example may be in order. Here's the incoming modelCollection: modelCollection = { "Washington, George", "Adams, John", "Jefferson, Thomas", "Madison, James" } Initialize the array with its element references all matching initial positions in the modelCollection: reSortIndices = { 0, 1, 2, 3 } After doing our sort in the array (where we sort indices based on the values in the modelCollection): reSortIndices = { 1, 2, 3, 0 } Then, we go back and apply that ordering to the modelCollection: modelCollection = { "Adams, John", "Jefferson, Thomas", "Madison, James", "Washington, George" } Why do it this way instead of just sorting the modelCollection directly? Because we may need to know the original index of the element e.g. for the auto sequence column.

Parameters:
modelCollection - the collection to sort
oldColumnSorts - the sorting that reflects the current state of the collection
newColumnSorts - the sorting to apply to the collection
collectionGroup - the CollectionGroup that is being rendered
view - the view

getTotalCollectionSize

public int getTotalCollectionSize()

getFilteredCollectionSize

public Integer getFilteredCollectionSize()

getTableLayoutManager

public TableLayoutManager getTableLayoutManager()


Copyright © 2005-2013 The Kuali Foundation. All Rights Reserved.