Closed wujincun closed 1 year ago
你好 @wujincun,请编辑你的 issue 标题, 一个言简意赅的 issue 标题可以节省大家的时间, 请不要将标题当做正文, 或者为空。
Hello, @wujincun, please edit your issue title. a concise issue title will save everyone time. please do not leave the title as the body or empty.
你好这个问题解决了么,我也遇到透视表排序有的列点击不生效
🏷 Version
Sheet Type
🖋 Description
透视表自定义排序,排序异常
⌨️ Code Snapshots
import React, { useEffect, useState } from "react"; import ReactDOM from "react-dom"; import { SheetComponent } from "@antv/s2-react"; import {toUpper} from 'lodash'
const SortMethodType = { asc: 'asc', desc: 'desc', none: 'none', }
const MENUS = [ { key: SortMethodType.none, text: '不排序' }, { key: SortMethodType.asc, text: '升序', icon: 'GroupAsc' }, { key: SortMethodType.desc, text: '降序', icon: 'GroupDesc' }, ];
const s2Options = { width: 600, height: 480, // 关闭默认icon showDefaultHeaderActionIcon: false, // 自定义 icon hierarchyType: "tree", tooltip: { showTooltip: true, }, };
const getHeaderActionIcons= (sortParams,sortHandle,sheetType)=>{ const sortParam = sortParams?.[0] const getIconName = (sortParam)=>{ const sortMethod = sortParam?.sortMethod const upSortMethod = toUpper(sortMethod) if (upSortMethod === 'ASC') { return 'groupAsc'; } if (upSortMethod === 'DESC') { return 'groupDesc'; } return 'SortDown'
} const getDisplayCondition = (meta,sheetType)=>{ const key = sheetType === 'table' ? sortParam?.sortFieldId : sortParam?.sortByMeasure const value = sheetType === 'table' ? meta.field : meta.value return key === value } const iconName = getIconName(sortParam) return [ { // 选择icon,可以是 S2 自带的,也可以是自定义的 icon iconNames:[ iconName], //getIconName(sortParam), // 通过 belongsCell + displayCondition 设置 icon 的展示位置 belongsCell: 'colCell', displayCondition: (meta)=> getDisplayCondition(meta,sheetType), // icon 点击之后的执行函数 action: (props) => {
}
const App = () => { const sortHandle = (meta, key) => { let sortParams = []; const rows = meta?.spreadsheet?.dataCfg?.fields?.rows; const sortFieldId = rows ? rows[rows.length - 1] : ""; sortParams = [ { sortFieldId: sortFieldId, sortMethod: key, sortByMeasure: meta.value, }, ]; setSortParams(sortParams) };
}
// 使用 ReactDOM.render( ,
document.getElementById('container'),
);
🔗 Reproduce Link
🤔 Steps to Reproduce
😊 Expected Behavior
多列表格,每一列的排序都正常
😅 Current Behavior
需求是单列排序,因此重写排序方法, 但是价格一列多次点击排序不生效,成本一列排序正常 项目中是s2-vue,demo使用的是react组件同样有问题
💻 System information