Tliashev.FF
Tliashev.FF

Reputation: 35

Ant Table fixed column width

  1. The column width is not set via the width property.
  2. If you set the width of the cells, the column will still stretch if the table container is enlarged.

Can you tell me, has anyone come across such a case?

my code:

  const columns = [
    {
      key: "a",
      dataIndex: "a",
      title: "A",
      width: "100px",
    },
    {
      key: "b",
      dataIndex: "b",
      title: "B",
      width: "50px",
    },
    {
      key: "c",
      dataIndex: "c",
      title: "C",
      width: "100px",
    },
    {
      key: "d",
      dataIndex: "d",
      title: "D",
      width: "100px",
    },

    {
      key: "e",
      dataIndex: "e",
      title: "E",
      width: "100px",
    },
  ];

  const dataSource = [
    { a: 1, b: 2, c: 3, d: 4, e: 5 },
    { a: 2, b: 3, c: 4, d: 5, e: 1 },
    { a: 3, b: 4, c: 5, d: 1, e: 2 },
    { a: 4, b: 5, c: 1, d: 2, e: 3 },
    { a: 5, b: 1, c: 2, d: 3, e: 4 },
  ];

  return (
    <div style={{ width: "100%" }}>
      <Table tableLayout="fixed" columns={columns} dataSource={dataSource} />
    </div>
  );
}```

Upvotes: 0

Views: 22

Answers (0)

Related Questions