Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🤔透视表:自定义列头;合并列头排序没有效果 #2889

Closed
4 tasks
dyllike3892654 opened this issue Sep 4, 2024 · 5 comments
Closed
4 tasks
Assignees
Labels
next 2.0-next 版本的问题 ❔question 疑问/使用问题

Comments

@dyllike3892654
Copy link

dyllike3892654 commented Sep 4, 2024

🏷 Version

Package Version
@antv/s2 2.0.0-next.26
@antv/s2-react ^2.0.0-next.25
@antv/s2-vue

Sheet Type

  • [√ ] PivotSheet
  • TableSheet
  • GridAnalysisSheet
  • StrategySheet
  • EditableSheet

🖋 Description

🔗 Reproduce Link

https://codesandbox.io/p/sandbox/infallible-ramanujan-4hxy9s?file=%2Fsrc%2Findex.js%3A108%2C26

问题:透视表合并表头后,点击排序不能打开tooltip框进行排序,点击行内排序没有效果

现在的效果:
image

想要的效果是像明细表一样可以列头分组也可以进行行内排序
image

😊 Expected Behavior

😅 Current Behavior

@dyllike3892654 dyllike3892654 added the ❔question 疑问/使用问题 label Sep 4, 2024
@github-actions github-actions bot added the next 2.0-next 版本的问题 label Sep 4, 2024
@lijinke666
Copy link
Member

lijinke666 commented Sep 10, 2024

你使用的是 s2-react, 所以应该用 <SheetComponent />, 这样才会渲染排序菜单, 而你提供的 demo 是用的 s2PivotSheet, 是没有 tooltip 的, 需要自行实现排序菜单的 ui, 所以没有效果.

image

另外没太看懂的是, 都用 s2-react 了, 根本不需要 headerActionIcons 呀, 自带排序菜单, 内部已经封装好了, 你这个 demo 是基于 @antv/s2 的写法.

另外你确定这个不是 <SheetComponent sheetType="table" /> ?

image

@lijinke666 lijinke666 self-assigned this Sep 10, 2024
@dyllike3892654
Copy link
Author

你好,我在本地用的是透视表,SheetComponent sheetType="pivot" 刚渲染的时候不会显示排序的Icon,只有自定义加上headerActionIcons才能显示出来Icon,像图片中的这样,
组件

@dyllike3892654
Copy link
Author

加入headerActionIcons后,会显示tooltip排序,但是没有排序效果
image

@dyllike3892654
Copy link
Author

麻烦看一下这个?image

下面是在React 组件自适应中复现的代码,用的是s2-react的透视表组件,合并成一级的列头都没有排序图标,不显示tooltip提示行内排序,点击现有的排序功能也无法进行排序

// organize-imports-ignore
import React from 'react';
import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';

fetch(
'https://gw.alipayobjects.com/os/bmw-prod/2a5dbbc8-d0a7-4d02-b7c9-34f6ca63cff6.json',
)
.then((res) => res.json())
.then((dataCfg) => {

const data = [
  {
    'measure-1': 13,
    'measure-2': 2,
    type: '家具',
    sub_type: '桌子',
  },
  {
    'measure-1': 11,
    'measure-2': 8,
    type: '家具',
    sub_type: '椅子',
  },
  {
    'measure-1': 21,
    'measure-2': 16,
    type: '家具',
    sub_type: '茶几',
  },
];

const s2DataConfig: S2DataConfig = {
  fields: {
    columns: [
      {
        field: 'a-1',
        title: '自定义节点 a-1',
        description: 'a-1 描述',
        children: [
          {
            field: 'a-1-1',
            title: '自定义节点 a-1-1',
            description: 'a-1-1 描述',
            children: [
              {
                field: 'measure-1',
                title: '指标 1',
                description: '指标 1 描述',
                children: [],
              },
              {
                field: 'measure-2',
                title: '指标 2',
                description: '指标 2 描述',
                children: [],
              },
            ],
          },
          {
            field: 'a-1-2',
            title: '自定义节点 a-1-2',
            description: 'a-1-2 描述',
            children: [],
          },
        ],
      },
      {
        field: 'a-2',
        title: '自定义节点 a-2',
        description: 'a-2 描述',
        children: [],
      },
    ],
    rows: ['type', 'sub_type'],
    values: ['measure-1', 'measure-2'],
    valueInCols: true,
  },
  data,
  // 自定义节点默认使用 `title` 作为展示名, 也可以通过 meta 来统一进行格式化
  meta: [
    {
      field: 'type',
      formatter: (value) => '商品类别',
    },
    {
      field: 'sub_type',
      formatter: (value) => '商品子类别',
    },
    {
      field: 'a-1',
      name: '角头1',
    },
    {
      field: 'a-1-1',
      name: '角头2',
    },
    // 自定义格式化数值
    // {
    //   field: 'measure-1',
    //   formatter: (value, record, meta) => `指标: ${value}`,
    // },
  ],
};

const s2Options: S2Options = {
  width: 600,
  height: 480,
  hierarchyType: 'grid',
};
reactDOMClient.createRoot(document.getElementById('container')).render(
  <SheetComponent
    dataCfg={s2DataConfig}
    options={s2Options}
    adaptive={{
      width: true,
      height: false,
      getContainer: () => document.getElementById('container'),
    }}
  />,
);

});

@dyllike3892654
Copy link
Author

dyllike3892654 commented Sep 18, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
next 2.0-next 版本的问题 ❔question 疑问/使用问题
Projects
None yet
Development

No branches or pull requests

2 participants