0% found this document useful (0 votes)
11 views1 page

Ej2 Grid1

Uploaded by

Maddula Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views1 page

Ej2 Grid1

Uploaded by

Maddula Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Powered by AI

Copilot

Sure, I can help with that. Here’s a basic example of how you can fetch data from a server for each page in a
Syncfusion EJ2 Grid using React. This example assumes that your server supports pagination and sorting.

import React from 'react';


import { DataManager, UrlAdaptor } from '@syncfusion/ej2-data';
import { GridComponent, ColumnsDirective, ColumnDirective, Page } from '@syncfusion/ej2-react-grids';

class App extends React.Component {


constructor() {
super(...arguments);
this.data = new DataManager({
url: 'https://your-server-url/api/data',
adaptor: new UrlAdaptor(),
crossDomain: true
});
}

render() {
return (
<GridComponent dataSource={this.data} allowPaging={true} pageSettings={{ pageSize: 10 }}>
<ColumnsDirective>
<ColumnDirective field='Column1' headerText='Column 1' />
<ColumnDirective field='Column2' headerText='Column 2' />
// Add more columns as needed
</ColumnsDirective>
<Page />
</GridComponent>
);
}
}

export default App;

In this code:

DataManager is used to manage the data flow in the Grid. It queries the data source and returns the result
based on the queries provided.
UrlAdaptor is used to interact with remote data services. It is used to make requests to the server for
sorting, paging, etc.
The GridComponent is the main component which displays the data. The dataSource prop is set to the
DataManager.
The allowPaging prop is set to true to enable pagination.
The pageSettings prop is used to set the page size.
The ColumnsDirective and ColumnDirective are used to define the columns in the Grid.

Please replace 'https://your-server-url/api/data' with your actual server URL. Also, make sure to replace
'Column1' and 'Column2' with your actual column field names.

This is a basic example. Depending on your requirements, you might need to handle additional cases such as
filtering, grouping, etc. Please refer to the official Syncfusion EJ2 Grid documentation for more details.

Remember to handle errors and edge cases in your code to ensure a robust application. Happy coding! 😊

You might also like