public class DataTablesPagingHelper extends Object
Modifier and Type | Class and Description |
---|---|
static class |
DataTablesPagingHelper.DataTablesInputs
Input command processor for supporting DataTables server-side processing.
|
Constructor and Description |
---|
DataTablesPagingHelper() |
Modifier and Type | Method and Description |
---|---|
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.
|
static void |
processPagingRequest(View view,
ViewModel form,
CollectionGroup collectionGroup,
DataTablesPagingHelper.DataTablesInputs dataTablesInputs) |
public DataTablesPagingHelper()
public static void processPagingRequest(View view, ViewModel form, CollectionGroup collectionGroup, DataTablesPagingHelper.DataTablesInputs dataTablesInputs)
protected static void applyTableJsonSort(List<Object> modelCollection, List<ColumnSort> oldColumnSorts, List<ColumnSort> newColumnSorts, CollectionGroup collectionGroup, ViewModel form, View view)
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.
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 viewCopyright © 2005–2015 The Kuali Foundation. All rights reserved.