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

[Feature Request] Table 增加重设列的尺寸 API #32811

Open
CHENJKNB opened this issue Nov 11, 2021 · 7 comments
Open

[Feature Request] Table 增加重设列的尺寸 API #32811

CHENJKNB opened this issue Nov 11, 2021 · 7 comments

Comments

@CHENJKNB
Copy link

CHENJKNB commented Nov 11, 2021

这个功能解决了什么问题?

希望Table组件做一个类似 fusion design 的重设列尺寸的API , 使用 asyncResizable 和 onResizeChange 调整列宽。如果左右锁列的列宽需要调整

你期望的 API 是怎样的?

const onChange = function(...args) {
    console.log(...args);
  },
  dataSource = () => {
    const result = [];
    for (let i = 0; i < 5; i++) {
      result.push({
        title: {
          name: `Quotation for 1PCS Nano ${3 + i}.0 controller compatible`
        },
        id: 100306660940 + i,
        time: 2000 + i
      });
    }
    return result;
  },
  render = (value, index, record) => {
    return <a href={`#${index}`}>Remove({record.id})</a>;
  },
  rowSelection = {
    onChange: onChange,
    getProps: record => {
      return {
        disabled: record.id === 100306660942
      };
    }
  };

class App extends React.Component {
  constructor(...args) {
    super(...args);
    this.state = {
      widths: {
        time: 300,
        [`title.name`]: 300
      }
    };
    this.onResizeChange = (dataIndex, value) => {
      const { widths } = this.state;
      widths[dataIndex] = widths[dataIndex] + value;
      this.setState({
        widths
      });
    };
  }
  render() {
    const { widths } = this.state;
    const time = widths.time;
    const name = widths[`title.name`];

    return (
      <Table
        dataSource={dataSource()}
        rowSelection={rowSelection}
        onResizeChange={this.onResizeChange}
      >
        <Table.Column lock title="Id" dataIndex="id" width={100} />
        <Table.Column
          title="Title"
          dataIndex={"title.name"}
          asyncResizable
          width={name}
        />
        <Table.Column
          title="Time"
          dataIndex="time"
          asyncResizable
          width={time}
        />
        <Table.Column cell={render} width={200} />
      </Table>
    );
  }
}

ReactDOM.render(<App />, mountNode);

其他

@pkaq
Copy link

pkaq commented Sep 6, 2022

非常必要的功能

@darkfiredarkhalo
Copy link

期待ing

@vaynevayne
Copy link

这就没了?

@AsuraKev
Copy link

AsuraKev commented Aug 4, 2023

any update?

@HaiJunCai8
Copy link

这个有计划做吗?很期待有这个功能啊

@hardmanhong
Copy link

用 react-resizable 遇到比较严重的性能问题

@piyushk96
Copy link

Unable to use react-resizable with antd v5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants