蚂蚁设计表如何显示空行

发布于 2025-02-09 21:06:02 字数 3187 浏览 0 评论 0原文

我正在使用表组件使用ANT设计,并且想知道即使它们是空的,即使它们是空的,是否可以始终显示10行。例如,我有一个带有11个项目的数据集。页面大小设置为10,因此第一页上显示的前十项显示,第二页上显示的最后一项显示。但是第二页仅显示一行,我希望它显示10(一个带有项目和9个空行)。

我该怎么做?我应该编写功能还是可以在表组件上使用的道具?

的示例:

这是我第二页的当前^^^我的表组件

import React from 'react';
import { Table } from 'antd';

const columns = [
  {
    title: 'Asylum Office',
    dataIndex: 'asylumOffice',
    key: 'asylumOffice',
  },
  {
    title: 'Citizenship',
    dataIndex: 'citizenship',
    key: 'citizenship',
  },
  {
    title: 'Race or Ethnicity',
    dataIndex: 'raceOrEthnicity',
    key: 'raceOrEthnicity',
  },
  {
    title: 'Case Outcome',
    dataIndex: 'caseOutcome',
    key: 'caseOutcome',
  },
  {
    title: 'Completion',
    dataIndex: 'completion',
    key: 'completion',
  },
  {
    title: 'Current Date',
    dataIndex: 'currentDate',
    key: 'currentDate',
  },
];

const data = [
  {
    key: '1',
    asylumOffice: 'AyS',
    citizenship: 'h',
    raceOrEthnicity: 'other',
    caseOutcome: 'pending',
    completion: 'n',
    currentDate: 'f',
  },
  {
    key: '2',
    asylumOffice: 'AWS',
    citizenship: 'A',
    raceOrEthnicity: 'other',
    caseOutcome: 'pending',
    completion: 'Y',
    currentDate: 'e',
  },
  {
    key: '3',
    asylumOffice: 'AyS',
    citizenship: 'h',
    raceOrEthnicity: 'latino',
    caseOutcome: 'pending',
    completion: 's',
    currentDate: 'f',
  },
  {
    key: '4',
    asylumOffice: 'AyS',
    citizenship: 'h',
    raceOrEthnicity: 'latino',
    caseOutcome: 'pending',
    completion: 's',
    currentDate: 'f',
  },
  {
    key: '5',
    asylumOffice: 'AyS',
    citizenship: 'h',
    raceOrEthnicity: 'latino',
    caseOutcome: 'pending',
    completion: 's',
    currentDate: 'f',
  },
  {
    key: '6',
    asylumOffice: 'AyS',
    citizenship: 'h',
    raceOrEthnicity: 'latino',
    caseOutcome: 'pending',
    completion: 's',
    currentDate: 'f',
  },
  {
    key: '7',
    asylumOffice: 'AyS',
    citizenship: 'h',
    raceOrEthnicity: 'latino',
    caseOutcome: 'pending',
    completion: 's',
    currentDate: 'f',
  },
  {
    key: '8',
    asylumOffice: 'AyS',
    citizenship: 'h',
    raceOrEthnicity: 'latino',
    caseOutcome: 'pending',
    completion: 's',
    currentDate: 'f',
  },
  {
    key: '9',
    asylumOffice: 'AyS',
    citizenship: 'h',
    raceOrEthnicity: 'latino',
    caseOutcome: 'pending',
    completion: 's',
    currentDate: 'f',
  },
  {
    key: '10',
    asylumOffice: 'AyS',
    citizenship: 'h',
    raceOrEthnicity: 'latino',
    caseOutcome: 'pending',
    completion: 's',
    currentDate: 'f',
  },
  {
    key: '11',
    asylumOffice: 'AyS',
    citizenship: 'h',
    raceOrEthnicity: 'latino',
    caseOutcome: 'pending',
    completion: 's',
    currentDate: 'f',
  },
];

function RenderTablePage(props) {
  return (
    <div>
      <Table
        columns={columns}
        dataSource={data}
        title={() => 'Tabular View'}
      />
    </div>
  );
}
export default RenderTablePage;

I'm working with ant design using the Table component and am wondering if there is a way to display 10 rows at all times even if they are empty. For example, I have a data set with 11 items. The page size is set to 10, so the first ten items show on the first page and the last item shows on the second page. But the second page displays only one row and I would like it to display 10 (one with the item and nine empty rows).

How can I go about doing this? Should I be writing a function or is there a prop I can use on the Table component?

enter image description here

This is an example of what my second page looks like currently ^^^

my table component:

import React from 'react';
import { Table } from 'antd';

const columns = [
  {
    title: 'Asylum Office',
    dataIndex: 'asylumOffice',
    key: 'asylumOffice',
  },
  {
    title: 'Citizenship',
    dataIndex: 'citizenship',
    key: 'citizenship',
  },
  {
    title: 'Race or Ethnicity',
    dataIndex: 'raceOrEthnicity',
    key: 'raceOrEthnicity',
  },
  {
    title: 'Case Outcome',
    dataIndex: 'caseOutcome',
    key: 'caseOutcome',
  },
  {
    title: 'Completion',
    dataIndex: 'completion',
    key: 'completion',
  },
  {
    title: 'Current Date',
    dataIndex: 'currentDate',
    key: 'currentDate',
  },
];

const data = [
  {
    key: '1',
    asylumOffice: 'AyS',
    citizenship: 'h',
    raceOrEthnicity: 'other',
    caseOutcome: 'pending',
    completion: 'n',
    currentDate: 'f',
  },
  {
    key: '2',
    asylumOffice: 'AWS',
    citizenship: 'A',
    raceOrEthnicity: 'other',
    caseOutcome: 'pending',
    completion: 'Y',
    currentDate: 'e',
  },
  {
    key: '3',
    asylumOffice: 'AyS',
    citizenship: 'h',
    raceOrEthnicity: 'latino',
    caseOutcome: 'pending',
    completion: 's',
    currentDate: 'f',
  },
  {
    key: '4',
    asylumOffice: 'AyS',
    citizenship: 'h',
    raceOrEthnicity: 'latino',
    caseOutcome: 'pending',
    completion: 's',
    currentDate: 'f',
  },
  {
    key: '5',
    asylumOffice: 'AyS',
    citizenship: 'h',
    raceOrEthnicity: 'latino',
    caseOutcome: 'pending',
    completion: 's',
    currentDate: 'f',
  },
  {
    key: '6',
    asylumOffice: 'AyS',
    citizenship: 'h',
    raceOrEthnicity: 'latino',
    caseOutcome: 'pending',
    completion: 's',
    currentDate: 'f',
  },
  {
    key: '7',
    asylumOffice: 'AyS',
    citizenship: 'h',
    raceOrEthnicity: 'latino',
    caseOutcome: 'pending',
    completion: 's',
    currentDate: 'f',
  },
  {
    key: '8',
    asylumOffice: 'AyS',
    citizenship: 'h',
    raceOrEthnicity: 'latino',
    caseOutcome: 'pending',
    completion: 's',
    currentDate: 'f',
  },
  {
    key: '9',
    asylumOffice: 'AyS',
    citizenship: 'h',
    raceOrEthnicity: 'latino',
    caseOutcome: 'pending',
    completion: 's',
    currentDate: 'f',
  },
  {
    key: '10',
    asylumOffice: 'AyS',
    citizenship: 'h',
    raceOrEthnicity: 'latino',
    caseOutcome: 'pending',
    completion: 's',
    currentDate: 'f',
  },
  {
    key: '11',
    asylumOffice: 'AyS',
    citizenship: 'h',
    raceOrEthnicity: 'latino',
    caseOutcome: 'pending',
    completion: 's',
    currentDate: 'f',
  },
];

function RenderTablePage(props) {
  return (
    <div>
      <Table
        columns={columns}
        dataSource={data}
        title={() => 'Tabular View'}
      />
    </div>
  );
}
export default RenderTablePage;

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

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

发布评论

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