logo

S2

  • Manual
  • API
  • Examples
  • Playground
  • ChangeLog
  • Productsantv logo arrow
  • 2.x
  • Introduction
  • Quick Start
  • Basic Tutorial
    • Base Concept
    • Sheet Type
      • Pivot Mode
        Updated
      • Table Mode
    • Conditions
      Updated
    • Totals
    • Sort
      • Custom Sort
        Updated
      • Group Sort
        Updated
    • Theme
      Updated
    • Tooltip
      Updated
    • Internationalization
    • 数据格式化
      New
    • Multi Line
      New
    • Pagination
      New
  • Advanced Tutorial
    • Advanced Tutorial
      • Link
      • Render Chart In Cell
      • Draw Chart With @antv/g2
    • Custom
      • Customize Hook
        Updated
      • Customize Tree
        New
      • Customize Icon
      • Customize Cell Alignment
      • Customize Cell Size
        Updated
      • Customize Order
      • Custom Collapse/Expand Nodes
    • Interaction
      • Basic Interaction
      • Custom Interaction
      • Hide Columns
      • Cell Resize
      • Merge Cell
      • Scroll
      • Copy
        New
      • Highlight and select cell
        New
    • Analyze Component
      • Introduction
        New
      • Advanced Sort
        Updated
      • Switcher
      • Export
        Updated
      • Pagination
      • Drill Down
    • Sheet Component
      • Editable Mode
      • Strategy Sheet
        Updated
    • HD Adapter
    • Get Instance
    • Get Cell Data
      Updated
    • Table adaptive
    • AntV/G Plugins
      New
    • Pivot Chart
      Experimental
    • Vue 3.0
  • Extended Reading
    • Data Process
      • Pivot
      • Table
    • Layout
      • Pivot
      • Table
    • Performance
      Updated
  • Contribution
  • FAQ
  • S2 2.0 Migration Guide

Advanced Sort

Previous
Introduction
Next
Switcher

Resources

Ant Design
Galacea Effects
Umi-React Application Framework
Dumi-Component doc generator
ahooks-React Hooks Library

Community

Ant Financial Experience Tech
seeconfSEE Conf-Experience Tech Conference

Help

GitHub
StackOverflow

more productsMore Productions

Ant DesignAnt Design-Enterprise UI design language
yuqueYuque-Knowledge creation and Sharing tool
EggEgg-Enterprise-class Node development framework
kitchenKitchen-Sketch Tool set
GalaceanGalacean-互动图形解决方案
xtechLiven Experience technology
© Copyright 2025 Ant Group Co., Ltd..备案号:京ICP备15032932号-38

Loading...

The React version provides an advanced sorting component, optionally available. view example

Note: state is not maintained internally

Get started quickly

Use the SheetComponent component of @antv/s2-react , and configure advancedSort for the header . For configuration details, see AdvancedSortCfgProps

import React, { useState } from 'react';
import ReactDOM from 'react-dom';
import { SortParams } from '@antv/s2';
import { SheetComponent } from '@antv/s2-react';
import '@antv/s2-react/dist/s2-react.min.css';
const AdvancedSortDemo = () => {
const [dataCfg, setDataCfg] = useState(s2DataConfig);
return (
<SheetComponent
sheetType="pivot"
adaptive={false}
dataCfg={dataCfg}
options={s2Options}
header={{
advancedSort: {
open: true,
sortParams: [{ sortFieldId: 'province', sortMethod: 'DESC' }],
onSortConfirm: (ruleValues, sortParams: SortParams) => {
setDataCfg({ ...dataCfg, sortParams });
},
},
}}
/>
);
};
ReactDOM.render(<AdvancedSortDemo />, document.getElementById('container'));

configuration

show

advancedSort: {
open: true,
}
row

submit

Through the onSortConfirm function, the selected rule data ruleValues and the data sortParams that can be processed into a table can be directly used

advancedSort: {
open: true,
onSortConfirm: (ruleValues: RuleValue[], sortParams: SortParams) => {
console.log(ruleValues, sortParams)
},
},

Customization

copy display

S2 provides display customization and rule copy customization for the entrance Button

parameterillustratetypeDefaultsrequired
classNameclass class namestring-
iconsort button iconReact.ReactNode-
textsort button nameReactNode-
ruleTextRule descriptionstring-
rowrow

dimension list

Support custom dimension list dimension , if not configured, the default is:行头+列头+数值

parameterillustratetypeDefaultsrequired
fielddimension idstring-✓
namedimension namestring-✓
listdimension liststring[]-✓
row

list for manual sorting

row

rule list

Support custom rule configuration list, if not configured, the default is:首字母、手动排序、其他字段

Note: If you customize here, you need to customize sortParams through ruleValues in onSortConfirm

AttributestyperequiredDefaultsFunctional description
labelstring✓rule name
value`'sortMethod''sortBy''sortByMeasure'`✓
childrenRuleOption[]✓rule sublist
row

Open sort popup

The onSortOpen: () => void callback can be used to support custom opening sorting pop-up windows, which are generally used to obtain pop-up frame data in advance