[]
        
(Showing Draft Content)

Sort and Filter

TableSheet provides column-based sorting and filtering at the View level.

Both behaviors are defined by View options and column configuration, and are executed through the column header filter button.

image

Sorting

Sorting Model

Each column has three possible states:

  • Ascending

  • Descending

  • None

sort.gif

By default, TableSheet supports multi-column sorting.

When multiple columns are sorted, the View maintains an ordered list of sort descriptors. Sorting is applied sequentially based on that order. Each subsequent sort operates within the result set produced by the previous sort.

multiSort.gif

Clearing all sorting restores the original data order.

Sorting Control

Multi-column Mode

Controlled by ITableSheetOptions.allowSorts:

interface GC.Spread.Sheets.TableSheet.ITableSheetOptions {
  allowSorts?: boolean; // Default: true
}
  • true — multiple active sorts allowed.

  • false — only one active sort is retained.

    If multiple sorts exist, only the first remains.

Automatic Re-sorting

Controlled by the View property:

view.autoSort = false;
  • Default: true

  • When enabled, editing values in sorted columns triggers re-sorting.

  • When disabled, edits do not reapply sorting.

Sorting Behavior

Applying Sorts

From the column menu:

  • Primary action — applies sorting to the column and clears other sorts.

  • Add/Remove action (multi-column mode only):

    • + adds the column to the active sort list.

    •  removes it.

The order in which columns are added determines sort priority.

When a sort is removed, remaining sort descriptors are reordered and data is re-evaluated accordingly.

addAndRemove.gif

Sort Indicators

Sorted columns display:

  • Direction (ascending or descending)

  • Sequence number (visible only when multiple sorts are active)

image

Indicators are hidden when no sorting is applied.

image

Sorting with Structured Data

Hierarchical Data

Sorting applies only to sibling nodes.

The hierarchy structure is preserved.

hierarchy.gif

Grouped Data

  • Grouped columns and their source columns share the same sorting state.

  • In multi-column mode, each group level may contain multiple sorts.

  • Sorting priority:

    1. Higher group levels

    2. Lower group levels

    3. Regular columns

  • Sorting on grouping-related columns may be reset if grouping structure changes.

group.gif

Cross Columns

Sorting can be applied to cross columns.

It may be lost if the data changes or the View columns are rebuilt.

cross..gif

Filtering

Filtering Model

Filtering is column-based and supports multiple active filters simultaneously.

Filtering Control

Filter Types

  • Filter by Value — condition-based filtering (text, number, date).

  • Filter by List — selection from distinct column values.

image

Column-level visibility of filter options is controlled by:

  • allowFilterByValue

  • allowFilterByList

Automatic Re-filtering

Controlled by:

view.autoFilter = true;
  • Default: false

  • When enabled, newly added or modified values are filtered out only if they match values already excluded by the active filter.

  • Otherwise, new values remain visible.

Column-Level Configuration

Sorting and filtering UI behavior can be configured per column:

  • allowSort

  • allowFilterByValue

  • allowFilterByList

var view = customerTable.addView("myView", [
  { value: "customerKey", allowSort: false, allowFilterByValue: false, allowFilterByList: false },
  { value: "customer", allowSort: false },
  { value: "billToCustomer", allowFilterByValue: false },
  { value: "category", allowFilterByList: false }
]);

sheet.setDataView(view);