Link Search Menu Expand Document

SSpread.BeforeUserSort Event

Occurs when sorting data.

※ Sorting has not been completed when this event occurs. Use the AfterUserSort event to perform processing that is expected to be performed after sorting is completed.

  • User clicks column header

  • Set $ColUserSortIndicatorAscending (sort / ascending order) and $ColUserSortIndicatorDescending (sort / descending order) in the ColUserSortIndicator property.

  • Set $UserColActionSort (sort / indicator display) and $UserColActionSortNoIndicator (sort / indicator hidden) in the UserColAction property.

The following child objects are attached to the Event object.

Type Name Description
Number Col Column number of the column to be sorted
Number State The type of sort that was performed last time
The following values are set.
Constant Name Description
$BeforeUserSortStateNone 0 No sorting
$BeforeUserSortStateAcending 1 Sort in ascending order
$BeforeUserSortStateDescending 2 Sort in descending order

Example of usage

Function OnBeforeUserSort (e) {
    var sortDescription;
    switch (e.State) {
        case $ BeforeUserSortStateNone:
            sortDescription = " Not sorted ";
            break;
        case $ BeforeUserSortStateAcending:
            sortDescription = " It was sorted in ascending order ";
            break;
        case $ BeforeUserSortStateDescending:
            sortDescription = " It was sorted in descending order ";
            break;
    }
    MessageBox (str (e.Col) + " column is " + sortDescription);
}

Related Item
ColUserSortIndicator, UserColAction property
AfterUserSort event