Getting Started with React Data Grid

To create a new Vite project, refer to the Vite documentation. Once that Vite project is ready to run with default settings, let’s add the React Data Grid component to the project.

Installing Syncfusion® React packages

To use the Data Grid component, install the @syncfusion/react-grid package:

Adding CSS reference

Import the Data Grid component's required CSS references as follows in src/App.css.

Adding Data Grid component

To include the Data Grid component in your application, import the Grid from @syncfusion/react-grid package in App.tsx.

Configuring the datasource

Create an employeeInformation.ts file and define a structured JSON dataset representing employee records. Then, import the employeeInformation module into your component and bind the data to the grid using the dataSource property.

Defining columns

Each column in the Data Grid is defined using the <Column> component. The field property maps column identifiers from the data source and displays their values, while the headerText property sets the user-defined title shown in each column header.

Enabling basic features

Add paging, sorting, searching, and filtering features to the grid.

Enabling basic events

The Data Grid component raises key events when rendering the grid, loading data, and performing actions like sorting, filtering, searching, paging, row selection, and deselection. These events help track the grid's event flow and indicate when data-related actions are complete.

Event NameDescription
onGridRenderStartFires an event when the grid begins rendering its rows, columns, and headers.
onDataLoadFires an event when data is successfully retrieved and notified to DOM initialization.
onGridRenderCompleteFires an event when the grid is fully loaded into the DOM and ready for user interaction.
onErrorFires an event when an error occurs during grid rendering or data operations.
onPageChangeFires an event when the user moved to a different page in the grid.
onSortFires an event when the grid is sorted based on a column.
onFilterFires an event when a filter is applied to the grid.
onSearchFires an event when search results are displayed in the grid.
onRowSelectFires an event when a row is selected.
onRowDeselectFires an event when a row is deselected.

Run the project

To run the project, use the following command:

Loading...