Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to place Ant Design Table in parent container bounds under React?

I develop a SPA application and I wish place table in parent element bounds but I can't set explicit height. I can set scroll.y of table body but then result total height is large by header height. I can't get header height to calculate total needed height. How I may place table into parent bounds?

<div style={{ width: '100vw', height: '100vh'}}>
<Table scroll={{ y: '100%' }} style={{ width: '100%', height: '100%' }}  pagination={false} columns={columns} dataSource={data} />

like image 203
Pavel Aristarkhov Avatar asked Jun 15 '18 07:06

Pavel Aristarkhov


People also ask

How do you use ant design tables in react?

import React from "react"; import { data } from "./Data"; import { Table } from "antd"; const App = () => { const [Data, setData] = useState(data); return ( <> <div className="app"> <div className="table"> <Table dataSource={Data} columns={columns} pagination={false} /> </div> </div> </> ); };

How do I add sorting to ANTD table?

Simply define a new sorting routine in utils/sorter. js , add it to the Sorter “enum,” and use it in your sorter prop for any column that needs it. You can check out the CodeSandbox for this tutorial to play around with the result.

How do I import an ANTD style?

Click the "Open in Editor" icon in the first example to open an editor with source code to use out-of-the-box. Now you can import the Alert component into the codesandbox: - import { DatePicker, message } from 'antd'; + import { DatePicker, message, Alert } from 'antd';


1 Answers

Seems like it's more of a CSS issue within Ant then a bug. it's a browser limitation.
Try working with vh units mixed with calc:

Example:

scroll={{ y: 'calc(100vh - 4em)' }}

Related Github discussion (require tranlation)

like image 118
vsync Avatar answered Nov 10 '22 08:11

vsync