Articles in this section
Category / Section

How to Show No Records Found Content in React ListView Component?

2 mins read

Follow these steps to display the “No records found” content in the React ListView component when the datasource is empty.

Step 1: Implement the ListView Component

Follow the Getting Started documentation to set up the Syncfusion React ListView component.

Step 2: Display “No records found” content

To display the “No records found” content, check if the data array is empty. If the data is empty, you can assign a default empty data content such as ([{ Name: ‘No records found’ }]) to the ListView’s dataSource property.

import { ListViewComponent } from '@syncfusion/ej2-react-lists';
function App() {
 //Define an array of JSON data
 let data = [];
 .....
 return (
   <div>
     <ListViewComponent
       id="list"
       ref={(listview) => {
         listviewInstance = listview;
       }}
       // Assign a default 'No records found' message if the data is empty
       dataSource={data.length === 0 ? [{ Name: 'No records found' }] : data}
       headerTitle="ListView"
       showHeader={true}
       width="350px"
       fields={fields}
     ></ListViewComponent>
   </div>
 );
} 

Sample: ListView-EmptyDataSource

See Also:

Conclusion
I hope you enjoyed learning how to show no records found content in React ListView component.
You can refer to our React ListView feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our React ListView example to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied