RealGrid2 API
Interface
SortingOptions

SortingOptions

Setting model for data sorting

Signature:

export interface SortingOptions

Remarks

When style is "exclusive", clicking the column header with the shift key operates as "inclusive".

When setting it as an option in Grid, you only need to enter the necessary information.

Example

grid.setSortingOptions({enabled: false});

Properties

PropertyTypeDescription
commitBeforeSortingbooleanWhether to commit before sorting
enabledbooleanWhether columns can be sorted by clicking on the column header
handleVisibilityHandleVisibilityHow to display filter handles
keepFocusedRowbooleanWhether to maintain the currently focused row when sorting
nullsOrderNullsOrderWhen sorting, place null, undefined, and '' first or last.
outerSortOuterSortCallback | booleanThe grid behaves as if it is sorted without actually sorting it.
pageSortingbooleanWhether to sort by current page
showSortOrderbooleanWhether to display sort order when sorting multiple columns
sortDataRowbooleanWhether to sort dataRows when the values ​​of the fields to be sorted are the same
styleSortStyleHow to specify sort status for multiple columns in a grid
textCaseSortCaseCase sensitive
toastToastOptionsToast-related settings

Properties Desc

commitBeforeSorting

Whether to commit before sorting

Type - boolean


enabled

Whether columns can be sorted by clicking on the column header

Type - boolean

Remarks:

orderBy() is executed regardless of the value of this property.


handleVisibility

How filter handles are displayed

Type - HandleVisibility


keepFocusedRow

Whether to maintain the currently focused row when sorting

Type - boolean


nullsOrder

When sorting, place null, undefined, and '' first or last.

Type - NullsOrder


outerSort

The grid behaves as if it is sorted without actually sorting it.

Type - OuterSortCallback | boolean

Remarks:

It is used when reloading sorted data from the server rather than sorting using data in the DataProvider.

If set to true, the user must specify the sorting state using grid.orderBy.

If you specify function, the function will be called just before the onSortingChanged event.

Example:

grid.sortingOptions.outerSort = true;
grid.onCellClicked = (grid, clickData) {
  // Example of sorting one field as the target
  if (clickData.cellType === "header") {
    const sortInfo = grid.getSortedFields();
    const fieldName = clickData.fieldName;
    const isSort = sortInfo && sortInfo.find(v => v.orgFieldName === fieldName);
    // let sortOrder = isSort ? (isSort.direction === 'ascending' ? 'descending' : null) : 'ascending';
    let sortOrder = (!isSort || isSort.direction === 'descending') ? 'ascending' : 'descending';
 
    if (sortOrder) {
      grid.orderBy([fieldName], [sortOrder]) // Grid only displays sort order in the header.
    } else {
      grid.orderBy([]);
    }
    getData(fieldName, sortOrder) // Perform dataProvider.setRows within getData.
  }
}

pageSorting

Whether to sort based on the current page

Type - boolean


showSortOrder

Whether to display sort order when sorting multiple columns

Type - boolean


sortDataRow

Whether to sort dataRows when the values ​​of the fields to be sorted are the same

Type - boolean


style

How to specify sort status for multiple columns in a grid

Type - SortStyle


textCase

Case sensitive

Type - SortCase


toast

Toast-related settings

Type - ToastOptions

Remarks:

It follows the ToastOptions model.