Class DataTablesPagingHelper
- Author:
- Kuali Rice Team (rice.collab@kuali.org)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classInput command processor for supporting DataTables server-side processing. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static voidapplyTableJsonSort(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.static voidprocessPagingRequest(View view, ViewModel form, CollectionGroup collectionGroup, DataTablesPagingHelper.DataTablesInputs dataTablesInputs)
-
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 sortoldColumnSorts- the sorting that reflects the current state of the collectionnewColumnSorts- the sorting to apply to the collectioncollectionGroup- the CollectionGroup that is being renderedform- object containing the view's dataview- the view
-