Skip to content

Commit

Permalink
Resolving comments
Browse files Browse the repository at this point in the history
  • Loading branch information
MarielaTihova committed Jan 9, 2025
1 parent 436ee41 commit 630ee69
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
11 changes: 5 additions & 6 deletions samples/grids/grid/remote-paging-grid/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,29 @@ export default function App() {
const [data, setData] = useState([]);
const [page, setPage] = useState(0);
const [perPage, setPerPage] = useState(15);
const [isLoading, setIsLoading] = useState(true);

useEffect(() => {
loadGridData(page, perPage);
}, [page, perPage]);

function loadGridData(pageIndex?: number, pageSize?: number) {
// Set loading state
setIsLoading(true);
// Set loading
grid.current.isLoading = true;

// Fetch data
RemoteService.getDataWithPaging(pageIndex, pageSize)
.then((response: CustomersWithPageResponseModel) => {
setData(response.items);
// Stop loading when data is retrieved
setIsLoading(false);
grid.current.isLoading = false;
paginator.current.totalRecords = response.totalRecordsCount;
})
.catch((error) => {
console.error(error.message);
setData([]);
// Stop loading even if error occurs. Prevents endless loading
setIsLoading(false);
grid.current.isLoading = false;

})
}

Expand All @@ -63,7 +63,6 @@ export default function App() {
pagingMode={GridPagingMode.Remote}
primaryKey="customerId"
height="600px"
isLoading={isLoading}
>
<IgrPaginator
perPage={perPage}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,30 @@ export default function App() {
const [data, setData] = useState([]);
const [page, setPage] = useState(0);
const [perPage, setPerPage] = useState(15);
const [isLoading, setIsLoading] = useState(true);

useEffect(() => {
loadGridData(page, perPage);
}, [page, perPage]);

function loadGridData(pageIndex?: number, pageSize?: number) {
// Set loading state
setIsLoading(true);
hierarchicalGrid.current.isLoading = true;

// Fetch data
RemoteService.getCustomersDataWithPaging(pageIndex, pageSize)
.then((response: CustomersWithPageResponseModel) => {
setData(response.items);
// Stop loading when data is retrieved
setIsLoading(false);
hierarchicalGrid.current.isLoading = false;

paginator.current.totalRecords = response.totalRecordsCount;
})
.catch((error) => {
console.error(error.message);
setData([]);
// Stop loading even if error occurs. Prevents endless loading
setIsLoading(false);
hierarchicalGrid.current.isLoading = false;

})
}

Expand All @@ -52,6 +53,8 @@ export default function App() {
parentKey: string
) {
const context = event.detail;
context.grid.isLoading = true;

const parentId: string = context.parentID;
const childDataKey: string = rowIsland.childDataKey;

Expand Down Expand Up @@ -88,7 +91,6 @@ export default function App() {
pagingMode={GridPagingMode.Remote}
primaryKey="customerId"
height="600px"
isLoading={isLoading}
>
<IgrPaginator
perPage={perPage}
Expand Down

0 comments on commit 630ee69

Please sign in to comment.