Class DataTablesPagingHelper

java.lang.Object
org.kuali.rice.krad.uif.layout.collections.DataTablesPagingHelper

public class DataTablesPagingHelper extends Object
Author:
Kuali Rice Team (rice.collab@kuali.org)
  • Constructor Details

    • DataTablesPagingHelper

      public DataTablesPagingHelper()
  • Method Details

    • processPagingRequest

      public static void processPagingRequest(View view, ViewModel form, CollectionGroup collectionGroup, DataTablesPagingHelper.DataTablesInputs dataTablesInputs)
    • applyTableJsonSort

      protected static void applyTableJsonSort(List<Object> modelCollection, List<ColumnSort> oldColumnSorts, List<ColumnSort> newColumnSorts, CollectionGroup collectionGroup, ViewModel form, 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
      form - object containing the view's data
      view - the view