簡體   English   中英

如何在頂部 antd 表中添加摘要?

[英]How to add summary at top antd table?

我可以在表格末尾添加摘要行。 但我需要在頂部添加它。 我怎樣才能在antd 表中做到這一點?

<Table
              columns={columns}
              dataSource={data}
              summary={pageData => {
                let totalWaste = 0;
                let totalBrick = 0;

                pageData.forEach(({ waste, brick }) => {
                  totalWaste += waste;
                  totalBrick += brick;
                });

                return (
                  <>
                    <thead>
                      <tr className="ant-table-row  ant-table-row-level-0">
                        <th>Summary</th>
                        <th></th>
                        <th></th>
                        <th>{totalWaste}</th>
                        <th>{totalBrick}</th>
                      </tr>
                    </thead>
                  </>
                );
              }}
            />

summary :正在tfoot中添加,並且沒有這樣的選項可以將summary用作第一行,

因此,我們可以不使用summary ,而是進行相同的計算,並在最初的object的原始數據中再添加一個 object。

工作演示

編輯總結 - Ant Design Demo


HACKED :在 header 子項中設置值以解決排序問題

編輯摘要 - Ant Design Demo 被黑

jsx:


<Table sticky  .../>

css:

.ant-table-summary {
      display: table-header-group;
}
<Table
  summary={() => <Table.Summary fixed="top">content</Table.Summary>}
  scroll={{ y: 500 }}
  ...
/>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM