Explore Courses
Liverpool Business SchoolLiverpool Business SchoolMBA by Liverpool Business School
  • 18 Months
Bestseller
Golden Gate UniversityGolden Gate UniversityMBA (Master of Business Administration)
  • 15 Months
Popular
O.P.Jindal Global UniversityO.P.Jindal Global UniversityMaster of Business Administration (MBA)
  • 12 Months
New
Birla Institute of Management Technology Birla Institute of Management Technology Post Graduate Diploma in Management (BIMTECH)
  • 24 Months
Liverpool John Moores UniversityLiverpool John Moores UniversityMS in Data Science
  • 18 Months
Popular
IIIT BangaloreIIIT BangalorePost Graduate Programme in Data Science & AI (Executive)
  • 12 Months
Bestseller
Golden Gate UniversityGolden Gate UniversityDBA in Emerging Technologies with concentration in Generative AI
  • 3 Years
upGradupGradData Science Bootcamp with AI
  • 6 Months
New
University of MarylandIIIT BangalorePost Graduate Certificate in Data Science & AI (Executive)
  • 8-8.5 Months
upGradupGradData Science Bootcamp with AI
  • 6 months
Popular
upGrad KnowledgeHutupGrad KnowledgeHutData Engineer Bootcamp
  • Self-Paced
upGradupGradCertificate Course in Business Analytics & Consulting in association with PwC India
  • 06 Months
OP Jindal Global UniversityOP Jindal Global UniversityMaster of Design in User Experience Design
  • 12 Months
Popular
WoolfWoolfMaster of Science in Computer Science
  • 18 Months
New
Jindal Global UniversityJindal Global UniversityMaster of Design in User Experience
  • 12 Months
New
Rushford, GenevaRushford Business SchoolDBA Doctorate in Technology (Computer Science)
  • 36 Months
IIIT BangaloreIIIT BangaloreCloud Computing and DevOps Program (Executive)
  • 8 Months
New
upGrad KnowledgeHutupGrad KnowledgeHutAWS Solutions Architect Certification
  • 32 Hours
upGradupGradFull Stack Software Development Bootcamp
  • 6 Months
Popular
upGradupGradUI/UX Bootcamp
  • 3 Months
upGradupGradCloud Computing Bootcamp
  • 7.5 Months
Golden Gate University Golden Gate University Doctor of Business Administration in Digital Leadership
  • 36 Months
New
Jindal Global UniversityJindal Global UniversityMaster of Design in User Experience
  • 12 Months
New
Golden Gate University Golden Gate University Doctor of Business Administration (DBA)
  • 36 Months
Bestseller
Ecole Supérieure de Gestion et Commerce International ParisEcole Supérieure de Gestion et Commerce International ParisDoctorate of Business Administration (DBA)
  • 36 Months
Rushford, GenevaRushford Business SchoolDoctorate of Business Administration (DBA)
  • 36 Months
KnowledgeHut upGradKnowledgeHut upGradSAFe® 6.0 Certified ScrumMaster (SSM) Training
  • Self-Paced
KnowledgeHut upGradKnowledgeHut upGradPMP® certification
  • Self-Paced
IIM KozhikodeIIM KozhikodeProfessional Certification in HR Management and Analytics
  • 6 Months
Bestseller
Duke CEDuke CEPost Graduate Certificate in Product Management
  • 4-8 Months
Bestseller
upGrad KnowledgeHutupGrad KnowledgeHutLeading SAFe® 6.0 Certification
  • 16 Hours
Popular
upGrad KnowledgeHutupGrad KnowledgeHutCertified ScrumMaster®(CSM) Training
  • 16 Hours
Bestseller
PwCupGrad CampusCertification Program in Financial Modelling & Analysis in association with PwC India
  • 4 Months
upGrad KnowledgeHutupGrad KnowledgeHutSAFe® 6.0 POPM Certification
  • 16 Hours
O.P.Jindal Global UniversityO.P.Jindal Global UniversityMaster of Science in Artificial Intelligence and Data Science
  • 12 Months
Bestseller
Liverpool John Moores University Liverpool John Moores University MS in Machine Learning & AI
  • 18 Months
Popular
Golden Gate UniversityGolden Gate UniversityDBA in Emerging Technologies with concentration in Generative AI
  • 3 Years
IIIT BangaloreIIIT BangaloreExecutive Post Graduate Programme in Machine Learning & AI
  • 13 Months
Bestseller
IIITBIIITBExecutive Program in Generative AI for Leaders
  • 4 Months
upGradupGradAdvanced Certificate Program in GenerativeAI
  • 4 Months
New
IIIT BangaloreIIIT BangalorePost Graduate Certificate in Machine Learning & Deep Learning (Executive)
  • 8 Months
Bestseller
Jindal Global UniversityJindal Global UniversityMaster of Design in User Experience
  • 12 Months
New
Liverpool Business SchoolLiverpool Business SchoolMBA with Marketing Concentration
  • 18 Months
Bestseller
Golden Gate UniversityGolden Gate UniversityMBA with Marketing Concentration
  • 15 Months
Popular
MICAMICAAdvanced Certificate in Digital Marketing and Communication
  • 6 Months
Bestseller
MICAMICAAdvanced Certificate in Brand Communication Management
  • 5 Months
Popular
upGradupGradDigital Marketing Accelerator Program
  • 05 Months
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in Corporate & Financial Law
  • 12 Months
Bestseller
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in AI and Emerging Technologies (Blended Learning Program)
  • 12 Months
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in Intellectual Property & Technology Law
  • 12 Months
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in Dispute Resolution
  • 12 Months
upGradupGradContract Law Certificate Program
  • Self paced
New
ESGCI, ParisESGCI, ParisDoctorate of Business Administration (DBA) from ESGCI, Paris
  • 36 Months
Golden Gate University Golden Gate University Doctor of Business Administration From Golden Gate University, San Francisco
  • 36 Months
Rushford Business SchoolRushford Business SchoolDoctor of Business Administration from Rushford Business School, Switzerland)
  • 36 Months
Edgewood CollegeEdgewood CollegeDoctorate of Business Administration from Edgewood College
  • 24 Months
Golden Gate UniversityGolden Gate UniversityDBA in Emerging Technologies with Concentration in Generative AI
  • 36 Months
Golden Gate University Golden Gate University DBA in Digital Leadership from Golden Gate University, San Francisco
  • 36 Months
Liverpool Business SchoolLiverpool Business SchoolMBA by Liverpool Business School
  • 18 Months
Bestseller
Golden Gate UniversityGolden Gate UniversityMBA (Master of Business Administration)
  • 15 Months
Popular
O.P.Jindal Global UniversityO.P.Jindal Global UniversityMaster of Business Administration (MBA)
  • 12 Months
New
Deakin Business School and Institute of Management Technology, GhaziabadDeakin Business School and IMT, GhaziabadMBA (Master of Business Administration)
  • 12 Months
Liverpool John Moores UniversityLiverpool John Moores UniversityMS in Data Science
  • 18 Months
Bestseller
O.P.Jindal Global UniversityO.P.Jindal Global UniversityMaster of Science in Artificial Intelligence and Data Science
  • 12 Months
Bestseller
IIIT BangaloreIIIT BangalorePost Graduate Programme in Data Science (Executive)
  • 12 Months
Bestseller
O.P.Jindal Global UniversityO.P.Jindal Global UniversityO.P.Jindal Global University
  • 12 Months
WoolfWoolfMaster of Science in Computer Science
  • 18 Months
New
Liverpool John Moores University Liverpool John Moores University MS in Machine Learning & AI
  • 18 Months
Popular
Golden Gate UniversityGolden Gate UniversityDBA in Emerging Technologies with concentration in Generative AI
  • 3 Years
Rushford, GenevaRushford Business SchoolDoctorate of Business Administration (AI/ML)
  • 36 Months
Ecole Supérieure de Gestion et Commerce International ParisEcole Supérieure de Gestion et Commerce International ParisDBA Specialisation in AI & ML
  • 36 Months
Golden Gate University Golden Gate University Doctor of Business Administration (DBA)
  • 36 Months
Bestseller
Ecole Supérieure de Gestion et Commerce International ParisEcole Supérieure de Gestion et Commerce International ParisDoctorate of Business Administration (DBA)
  • 36 Months
Rushford, GenevaRushford Business SchoolDoctorate of Business Administration (DBA)
  • 36 Months
Liverpool Business SchoolLiverpool Business SchoolMBA with Marketing Concentration
  • 18 Months
Bestseller
Golden Gate UniversityGolden Gate UniversityMBA with Marketing Concentration
  • 15 Months
Popular
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in Corporate & Financial Law
  • 12 Months
Bestseller
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in Intellectual Property & Technology Law
  • 12 Months
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in Dispute Resolution
  • 12 Months
IIITBIIITBExecutive Program in Generative AI for Leaders
  • 4 Months
New
IIIT BangaloreIIIT BangaloreExecutive Post Graduate Programme in Machine Learning & AI
  • 13 Months
Bestseller
upGradupGradData Science Bootcamp with AI
  • 6 Months
New
upGradupGradAdvanced Certificate Program in GenerativeAI
  • 4 Months
New
KnowledgeHut upGradKnowledgeHut upGradSAFe® 6.0 Certified ScrumMaster (SSM) Training
  • Self-Paced
upGrad KnowledgeHutupGrad KnowledgeHutCertified ScrumMaster®(CSM) Training
  • 16 Hours
upGrad KnowledgeHutupGrad KnowledgeHutLeading SAFe® 6.0 Certification
  • 16 Hours
KnowledgeHut upGradKnowledgeHut upGradPMP® certification
  • Self-Paced
upGrad KnowledgeHutupGrad KnowledgeHutAWS Solutions Architect Certification
  • 32 Hours
upGrad KnowledgeHutupGrad KnowledgeHutAzure Administrator Certification (AZ-104)
  • 24 Hours
KnowledgeHut upGradKnowledgeHut upGradAWS Cloud Practioner Essentials Certification
  • 1 Week
KnowledgeHut upGradKnowledgeHut upGradAzure Data Engineering Training (DP-203)
  • 1 Week
MICAMICAAdvanced Certificate in Digital Marketing and Communication
  • 6 Months
Bestseller
MICAMICAAdvanced Certificate in Brand Communication Management
  • 5 Months
Popular
IIM KozhikodeIIM KozhikodeProfessional Certification in HR Management and Analytics
  • 6 Months
Bestseller
Duke CEDuke CEPost Graduate Certificate in Product Management
  • 4-8 Months
Bestseller
Loyola Institute of Business Administration (LIBA)Loyola Institute of Business Administration (LIBA)Executive PG Programme in Human Resource Management
  • 11 Months
Popular
Goa Institute of ManagementGoa Institute of ManagementExecutive PG Program in Healthcare Management
  • 11 Months
IMT GhaziabadIMT GhaziabadAdvanced General Management Program
  • 11 Months
Golden Gate UniversityGolden Gate UniversityProfessional Certificate in Global Business Management
  • 6-8 Months
upGradupGradContract Law Certificate Program
  • Self paced
New
IU, GermanyIU, GermanyMaster of Business Administration (90 ECTS)
  • 18 Months
Bestseller
IU, GermanyIU, GermanyMaster in International Management (120 ECTS)
  • 24 Months
Popular
IU, GermanyIU, GermanyB.Sc. Computer Science (180 ECTS)
  • 36 Months
Clark UniversityClark UniversityMaster of Business Administration
  • 23 Months
New
Golden Gate UniversityGolden Gate UniversityMaster of Business Administration
  • 20 Months
Clark University, USClark University, USMS in Project Management
  • 20 Months
New
Edgewood CollegeEdgewood CollegeMaster of Business Administration
  • 23 Months
The American Business SchoolThe American Business SchoolMBA with specialization
  • 23 Months
New
Aivancity ParisAivancity ParisMSc Artificial Intelligence Engineering
  • 24 Months
Aivancity ParisAivancity ParisMSc Data Engineering
  • 24 Months
The American Business SchoolThe American Business SchoolMBA with specialization
  • 23 Months
New
Aivancity ParisAivancity ParisMSc Artificial Intelligence Engineering
  • 24 Months
Aivancity ParisAivancity ParisMSc Data Engineering
  • 24 Months
upGradupGradData Science Bootcamp with AI
  • 6 Months
Popular
upGrad KnowledgeHutupGrad KnowledgeHutData Engineer Bootcamp
  • Self-Paced
upGradupGradFull Stack Software Development Bootcamp
  • 6 Months
Bestseller
KnowledgeHut upGradKnowledgeHut upGradBackend Development Bootcamp
  • Self-Paced
upGradupGradUI/UX Bootcamp
  • 3 Months
upGradupGradCloud Computing Bootcamp
  • 7.5 Months
PwCupGrad CampusCertification Program in Financial Modelling & Analysis in association with PwC India
  • 5 Months
upGrad KnowledgeHutupGrad KnowledgeHutSAFe® 6.0 POPM Certification
  • 16 Hours
upGradupGradDigital Marketing Accelerator Program
  • 05 Months
upGradupGradAdvanced Certificate Program in GenerativeAI
  • 4 Months
New
upGradupGradData Science Bootcamp with AI
  • 6 Months
Popular
upGradupGradFull Stack Software Development Bootcamp
  • 6 Months
Bestseller
upGradupGradUI/UX Bootcamp
  • 3 Months
PwCupGrad CampusCertification Program in Financial Modelling & Analysis in association with PwC India
  • 4 Months
upGradupGradCertificate Course in Business Analytics & Consulting in association with PwC India
  • 06 Months
upGradupGradDigital Marketing Accelerator Program
  • 05 Months

How to Make Ant Design Table (AntD) in React JS

Updated on 23 June, 2023

7.47K+ views
7 min read

Introduction to Ant Design Table (AntD)

Ant Design Table, or AntD Table, is a powerful and feature-rich component that the Ant Design framework provides for ReactJS. Its comprehensive functionalities make it an excellent choice for displaying and manipulating tabular data in web applications. 

Enhance your skills with Ant Design Table by signing up for a Full Stack Software Development Bootcamp.

Setting Up an Ant React Table

Follow these steps to set up an Ant Design Table in a ReactJS project:

  • Install Ant Design: npm install antd
  • Import necessary components: import { Table } from ‘antd’;
  • Use the <Table> component, providing data and column configuration as props.
  • Customise the dataSource and columns arrays.
  • Render the Table component in your React component hierarchy.

Check out our free technology courses to get an edge over the competition.

Creating a Basic Ant Table

Follow these steps to create a basic React Ant Design Table:

  • Install Ant Design and import the components and styles required.
  • Define the Table’s data source and column configuration:
  • Render the Table component in your React component:
  • Use the <MyTable /> component to display the Table wherever you want.
  • Explore additional Ant Design (React) features and options to customise it further.

Customising Table Columns and Rows

Customise Ant Design Tables and rows with ReactJS using various AntD properties and components. Follow the steps below:

  • Install Ant Design and import the components and styles required.
  • Create a custom Table component with columns and data.
  • Customise the Table appearance using properties like rowClassName.
  • Define custom CSS styles for Table rows.

Sharpen your AntD skills with a comprehensive course like the Master of Science in Computer Science from LJMU.

Sorting and Filtering Data in AntD Table

Use the library’s built-in features and properties to enable sorting and filtering in an Ant Design (AntD) Table by following the given steps:

  • Import the necessary components and styles from Ant Design.
  • Create a state variable to store the filtered data.
  • Define your Table’s columns and add the sorter and filter properties.
  • Define the data for your Table.
  • Render the Table component with the defined columns, data, and filtering properties.
  • Implement the onChange event handler to sort and filter.
  • When sorting is triggered, use the sorter object to determine the column key and sorting order. Sort the data accordingly and update the state with the sorted data.
  • Use the filter object to determine the column key and filter value once filtering is triggered. Filter the data based on the provided value and update the state with the filtered data.
  • If no sorting or filtering is applied, reset the filtered data state to an empty array.
  • Render the custom Table component in your application.

Paginating and Grouping Data in AntD Table

Use the pagination and row grouping features provided by AntD to paginate and group data in an Ant Design (AntD) Table using ReactJS. 

  • Import the necessary components and styles from AntD
  • Define the columns and data for your Table.
  • Set up pagination:
  • Define a state variable to store the current page number and items per page.
  • Implement an onChange event handler to update the state when the page changes or the items per page are modified.
  • Render the Pagination component, passing the current page and the total number of items as props.
  • Group rows in the Table:
  • Define a rowKey for each row to ensure uniqueness.
  • Use the rowSpan property to specify the number of rows a particular cell should span within a group.
  • Render the Table:
  • Pass the columns and data to the Table component as props.
  • Use the pagination prop to enable pagination, passing the current page and items per page state variables.
  • For row grouping, use the rowSpan property within columns where grouping is required.

Adding Selections and Actions to AntD Table

To add selections and actions to an Ant Design (AntD) Table using ReactJS:

  • Import the necessary components and styles from AntD.
  • Define a state variable to store the selected row keys.
  • Use the rowSelection property in the Table component to enable row selection, passing the selected row keys and an onChange event handler.
  • Implement the onChange event handler to update the selected row keys state.
  • Add additional columns to the Table component to display actions or checkboxes for each row.
  • Implement action or checkbox event handlers to perform desired actions based on the selected rows.
  • Customise the actions or checkboxes display using the render or customRender property in the columns.
  • Optionally, customise the appearance of selected rows using the rowClassName property.
  • Render the Table component in your application.

Implementing Search and Highlighting in AntD Table

To implement search functionality and highlighting in an Ant Design (AntD) Table using ReactJS:

  • Define a state variable to store the search input value and a filtered data state variable.
  • Implement an onSearch event handler to update the search input value state and filter the data based on the input value.
  • Render a search input component and bind it to the onSearch event handler.
  • Display the filtered rows in the Table using the filtered data state variable.
  • Implement a highlighting mechanism in the Table:
  • Define a function that takes the search input value and cell data as arguments and returns the highlighted text.
  • In the column’s render or customRender property, apply the highlighting function to the cell data using JSX.
  • Render the Table component in your application.

Adding Loading and Error States to AntD Table

To add loading and error states to an Ant Design (AntD) Table using ReactJS:

  • Define a state variable to track the loading state and an error state variable.
  • Set the initial loading state to true and the error state to false.
  • Use an asynchronous function or API call to fetch the data for the Table.
  • Within the function or API call, update the loading state accordingly.
  • If an error occurs during the data fetching process, update the error state to true.
  • Render the Table component with the loading prop set to the loading state variable.
  • Optionally, handle the error state in the component’s rendering logic by displaying an error message or taking appropriate actions.
  • Customise the loading state appearance using the Spin component or other AntD-provided loading indicators.
  • Render the Table component and handle your application’s error and loading states.

Integrating AntD Table with Backend APIs

To integrate an Ant Design (AntD) Table with backend APIs in ReactJS:

  • Define a state variable to store the data fetched from the backend API.
  • Use a lifecycle method (e.g., useEffect) or an event handler to make an API request to fetch the data from the backend.
  • Within the API request, update the state variable with the fetched data.
  • Render the Table component with the data obtained from the backend API.
  • Customise the columns based on the data structure received from the API.
  • Optionally, handle error scenarios and loading states while fetching data from the backend.
  • Customise the Table appearance and behaviour using AntD’s properties, such as pagination, sorting, and filtering, to match the API response and user requirements.
  • Implement event handlers or callback functions to handle actions performed on the Table, such as editing or deleting data.
  • Make API requests to update the backend data based on the user’s actions.

Best Practices and Tips for Working with AntD Table

Follow these best practices and tips when working with Ant Design (AntD) Table:

  • Assign unique keys to columns for improved performance and to avoid rendering issues.
  • Implement server-side pagination and filtering to reduce the amount of data fetched and improve loading times.
  • Use memorisation techniques like React.memo or useMemo to optimise rendering for column cells or custom components.
  • Employ virtual scrolling or lazy loading techniques for Tables with many rows to enhance performance.
  • Use built-in row selection and action features to handle bulk operations efficiently.
  • Leverage AntD’s APIs and styling options to customise Table appearance and behaviour to match your design and requirements.
  • Ensure the Table’s accessibility by providing appropriate labels, keyboard navigation, and ARIA attributes.

Future Updates and Developments in AntD Table

Since its inception, AntD has been periodically optimised with regular updates, bug fixes and new features. With the latest update of AntD version 5.6.2 released on 19th June 2023, this Table component has received many features, style addons, bug fixes and Table fixes. 

As for future updates, AntD is set to receive weekly bug fixes and minor version monthly releases. 

Conclusion

Creating an Ant Design (AntD) Table in ReactJS is a powerful way to display and manage tabular data in your applications. Follow the provided steps and leverage the extensive features and customisation options offered by AntD to create interactive and efficient Tables, enhancing user experience and streamlining data presentation. 

Register for upGrad’s Executive PG Programme in Full Stack Development from IIITB and start building your feature-rich Tables with AntD.

Frequently Asked Questions (FAQs)

1. How to add filters to an AntD Table?

To add filters to an AntD Table, define the filter options for each column and use the filter property in the Table's columns configuration.

2. How can an Ant design Table be made responsive?

An Ant Design Table can be made responsive using CSS media queries and responsive design techniques.

3. How to style an AntD Table?

To style an AntD Table, customise the Table's appearance by using the provided styling options.

RELATED PROGRAMS