Skip to content

Commit b734ed2

Browse files
committed
update(sample): updated remote paging sample to 19
1 parent 6354bb6 commit b734ed2

1 file changed

Lines changed: 12 additions & 24 deletions

File tree

  • samples/grids/grid/remote-paging-grid/src
Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
11
import React, { useEffect, useRef, useState } from "react";
2-
32
import ReactDOM from "react-dom/client";
4-
import "./index.css";
5-
6-
import { IgrGrid, IgrPaginator, IgrGridModule, GridPagingMode } from "igniteui-react-grids";
3+
import { IgrGrid, IgrPaginator, GridPagingMode } from "igniteui-react-grids";
74
import { IgrColumn } from "igniteui-react-grids";
8-
95
import "igniteui-react-grids/grids/combined";
106
import "igniteui-react-grids/grids/themes/light/bootstrap.css";
117
import { RemoteService } from "./RemotePagingService";
128
import { CustomersWithPageResponseModel } from "./CustomersWithPageResponseModel";
139
import { IgrNumberEventArgs } from "igniteui-react";
1410

15-
IgrGridModule.register();
16-
1711
export default function App() {
1812
const grid = useRef<IgrGrid>(null);
1913
const paginator = useRef<IgrPaginator>(null);
@@ -26,31 +20,26 @@ export default function App() {
2620
}, [page, perPage]);
2721

2822
function loadGridData(pageIndex?: number, pageSize?: number) {
29-
// Set loading
3023
grid.current.isLoading = true;
3124

32-
// Fetch data
3325
RemoteService.getDataWithPaging(pageIndex, pageSize)
3426
.then((response: CustomersWithPageResponseModel) => {
3527
setData(response.items);
36-
// Stop loading when data is retrieved
3728
grid.current.isLoading = false;
3829
paginator.current.totalRecords = response.totalRecordsCount;
3930
})
4031
.catch((error) => {
4132
console.error(error.message);
4233
setData([]);
43-
// Stop loading even if error occurs. Prevents endless loading
4434
grid.current.isLoading = false;
45-
46-
})
35+
});
4736
}
4837

49-
function onPageNumberChange(paginator: IgrPaginator, args: IgrNumberEventArgs) {
38+
function onPageNumberChange(args: IgrNumberEventArgs) {
5039
setPage(args.detail);
5140
}
5241

53-
function onPageSizeChange(paginator: IgrPaginator, args: IgrNumberEventArgs) {
42+
function onPageSizeChange(args: IgrNumberEventArgs) {
5443
setPerPage(args.detail);
5544
}
5645

@@ -60,29 +49,28 @@ export default function App() {
6049
<IgrGrid
6150
ref={grid}
6251
data={data}
63-
pagingMode={GridPagingMode.Remote}
52+
pagingMode={"remote"}
6453
primaryKey="customerId"
6554
height="600px"
6655
>
67-
<IgrPaginator
68-
perPage={perPage}
69-
ref={paginator}
70-
pageChange={onPageNumberChange}
71-
perPageChange={onPageSizeChange}>
72-
</IgrPaginator>
56+
<IgrPaginator
57+
perPage={perPage}
58+
ref={paginator}
59+
onPageChange={onPageNumberChange}
60+
onPerPageChange={onPageSizeChange}
61+
></IgrPaginator>
7362
<IgrColumn field="customerId" hidden={true}></IgrColumn>
7463
<IgrColumn field="companyName" header="Company Name"></IgrColumn>
7564
<IgrColumn field="contactName" header="Contact Name"></IgrColumn>
7665
<IgrColumn field="contactTitle" header="Contact Title"></IgrColumn>
7766
<IgrColumn field="address.country" header="Country"></IgrColumn>
7867
<IgrColumn field="address.phone" header="Phone"></IgrColumn>
7968
</IgrGrid>
80-
8169
</div>
8270
</div>
8371
);
8472
}
8573

86-
// rendering above component in the React DOM
74+
// Render the component
8775
const root = ReactDOM.createRoot(document.getElementById("root"));
8876
root.render(<App />);

0 commit comments

Comments
 (0)