最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Customize React Antd table header with table data - Stack Overflow

programmeradmin10浏览0评论

In my React project, I need to customize antd table header as follows

I have added sample code bellow.

I need to have Sum of the amount in the header of the Amount column

Sample Code:

In my React project, I need to customize antd table header as follows

I have added sample code bellow.

I need to have Sum of the amount in the header of the Amount column

Sample Code:

https://codesandbox.io/embed/great-sun-534cd

Share Improve this question asked Jun 21, 2019 at 6:07 Janith WidarshanaJanith Widarshana 3,48310 gold badges55 silver badges77 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 14

You can use title function like this for get total of amount fields

const columns = [

    {
      title: () => { 
        var total = 0;
        for(var i=0;i<data.length;i++){
          total += data[i].amount;
        }
        return <div>total {total}</div>;
      } ,
      dataIndex: "date",
      width: 200
    },
    {
      title: "Amount",
      dataIndex: "amount",
      width: 100
    }
  ];

Example link here https://codesandbox.io/s/festive-wiles-st6wl?fontsize=14

发布评论

评论列表(0)

  1. 暂无评论