如何使用react js和antd添加两个静态行

发布于 2025-01-16 11:09:09 字数 2697 浏览 2 评论 0原文

我目前正在使用 antd 表 我知道如何在 antd 表中添加一个静态行 现在我想将两个数据分组到静态行中,例如一个有工作的数据应该在工作下方,一个有发票的数据应该在发票下方,如下所示 输入图片此处描述

我目前是这样做的:

const columns = [
        {
          title: "Date Due",
          dataIndex: "date_due",
          sorter: (a, b) => {
            return a?.date_due?.localeCompare(b?.date_due);
          },
    
          children: [
            {
              title: "Jobs",
              dataIndex: "job",
              key: "date_scheduled",
              render: (text, record) => (
                  record?.date_scheduled
              ),
            },
          ],
  children: [
    {
      title: "Invoice",
      dataIndex: "invoice",
      key: "date_scheduled",
      render: (text, record) => record?.date_scheduled,
    },
  ],
          sorter: (a, b) => {
            return a?.date_scheduled?.localeCompare(b?.date_scheduled);
          },
        },
        {
          title: "Status",
          children: [
            {
              dataIndex: "status",
              key: "status",
              render: (text, record) => (
                  record?.status
              ),
            },
          ],
          sorter: (a, b) => {
            return a?.status?.localeCompare(b?.status);
          },
        },
        {
          title: "Amount",
          children: [
            {
              dataIndex: "amount",
              key: "amount_due",
              render: (text, record) => (
                  record?.amount_due
              ),
            },
          ],
          sorter: (a, b) => {
            return a?.amount_due?.localeCompare(b?.amount_due);
          },
        },
        {
          title: "Actions",
          children: [
            {
              dataIndex: "action",
              key: "action",
              render: (text, record) => (
                <>
                <Button
                  className="default-btn"
                  icon={<CloseOutlined />}
                  style={{
                    backgroundColor: "#D15B47",
                    color: "#ffffff",
                    borderColor: "#87B87F",
                    borderRadius: "10px",
                  }}
                />
              </>
              ),
            },
          ],
        },
      ];

但是这样我只能得到一个像这样的静态行 输入图片此处描述最后的孩子在这里显示 我也无法添加没有工作添加到帐单中,并且没有发票添加到帐单中,如果没有任何信息

那么任何人都可以帮助我解决这个问题吗? 先感谢您

I am currently using antd table i know how to add one static row in antd table
Now i want to group two data into static rows like one having jobs should end up below jobs and one having invoice should end up below invoice Like This
enter image description here

I have currently did it like this :

const columns = [
        {
          title: "Date Due",
          dataIndex: "date_due",
          sorter: (a, b) => {
            return a?.date_due?.localeCompare(b?.date_due);
          },
    
          children: [
            {
              title: "Jobs",
              dataIndex: "job",
              key: "date_scheduled",
              render: (text, record) => (
                  record?.date_scheduled
              ),
            },
          ],
  children: [
    {
      title: "Invoice",
      dataIndex: "invoice",
      key: "date_scheduled",
      render: (text, record) => record?.date_scheduled,
    },
  ],
          sorter: (a, b) => {
            return a?.date_scheduled?.localeCompare(b?.date_scheduled);
          },
        },
        {
          title: "Status",
          children: [
            {
              dataIndex: "status",
              key: "status",
              render: (text, record) => (
                  record?.status
              ),
            },
          ],
          sorter: (a, b) => {
            return a?.status?.localeCompare(b?.status);
          },
        },
        {
          title: "Amount",
          children: [
            {
              dataIndex: "amount",
              key: "amount_due",
              render: (text, record) => (
                  record?.amount_due
              ),
            },
          ],
          sorter: (a, b) => {
            return a?.amount_due?.localeCompare(b?.amount_due);
          },
        },
        {
          title: "Actions",
          children: [
            {
              dataIndex: "action",
              key: "action",
              render: (text, record) => (
                <>
                <Button
                  className="default-btn"
                  icon={<CloseOutlined />}
                  style={{
                    backgroundColor: "#D15B47",
                    color: "#ffffff",
                    borderColor: "#87B87F",
                    borderRadius: "10px",
                  }}
                />
              </>
              ),
            },
          ],
        },
      ];

But with this i can get only one static row like this
enter image description here
The last children is shown here
And i also i couldn't add No jobs added to the bill and no invoice added to the bill if there ain't any information

So can any one please help me with this
Thankyou in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文