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

Table

Previous
Pivot
Next
Pivot

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...

This article will introduce the data flow processing process of the schedule, so that readers can understand the internal data logic of S2 more intuitively. The data processing flow of the detailed table is simpler than that of the pivot table, mainly for filtering and sorting, and preprocessing the data.

Raw data

The initial configuration and data are as follows:

const dataCfg = {
fields: {
columns: ['city', 'type', 'sub_type', 'price'],
},
data: [{
"price": 1,
"province": "浙江省",
"city": "杭州市",
"type": "家具",
"sub_type": "桌子"
}, {
"price": 2,
"province": "浙江省",
"city": "绍兴市",
"type": "家具",
"sub_type": "桌子"
}, {
"price": 3,
"province": "浙江省",
"city": "杭州市",
"type": "家具",
"sub_type": "沙发"
}, {
"price": 4,
"province": "浙江省",
"city": "绍兴市",
"type": "家具",
"sub_type": "沙发"
}]
};
const options = {
width: 800,
height: 600
};
<SheetComponent
dataCfg={dataCfg}
options={options}
sheetType="table"
/>

Sort, filter and generate display data

If the user configures filtering and sorting, S2 will process the raw data to generate filtered and sorted display data.

For example, if the user configures the filter:

// dataCfg
{
filterParams: [
{
filterKey: 'city',
filteredValues: ['杭州市'],
customFilter: (row) => row['city'] === '杭州市' || row['city'] === '宁波市',
}
]
}

This time, S2 will filter the city field, and only keep the records whose value is Hangzhou:

[
{
"price": 1,
"province": "浙江省",
"city": "杭州市",
"type": "家具",
"sub_type": "桌子"
},
{
"price": 3,
"province": "浙江省",
"city": "杭州市",
"type": "家具",
"sub_type": "沙发"
},
]

If user configured sorting:

// dataCfg
{
sortParams: [
{
sortFieldId: 'price',
sortMethod: 'DESC'
}
]
}

S2 will sort the price field in descending order, and the data will eventually become like this:

[
{
"price": 3,
"province": "浙江省",
"city": "杭州市",
"type": "家具",
"sub_type": "沙发"
},
{
"price": 1,
"province": "浙江省",
"city": "杭州市",
"type": "家具",
"sub_type": "桌子"
},
]

retrieve data

The above data will be saved in the field named displayData in TableDataSet . The original data originally passed in by the user will not be modified.

We can get it through s2Instance.dataSet.displayData .

At the same time, the data of a row and column can be obtained through the s2Instance.dataSet.getCellData({ rowIndex: number; col: number; }) API. Similarly, what is obtained here is the display data after filtering and sorting.