Skip to content

Commit

Permalink
Update DataViewLazyDemo.js
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Jun 4, 2021
1 parent 57b596a commit 49a26c7
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/showcase/dataview/DataViewLazyDemo.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,12 @@ export class DataViewLazyDemo extends Component {
//imitate delay of a backend call
setTimeout(() => {
const startIndex = event.first;
const endIndex = event.first + this.rows;
const endIndex = Math.min(event.first + this.rows, this.state.totalRecords - 1);
const newProducts = startIndex === endIndex ? this.datasource.slice(startIndex) : this.datasource.slice(startIndex, endIndex);

this.setState({
first: startIndex,
products: this.datasource.slice(startIndex, endIndex),
products: newProducts,
loading: false
});
}, 1000);
Expand Down Expand Up @@ -219,11 +220,12 @@ export class DataViewLazyDemo extends Component {
//imitate delay of a backend call
setTimeout(() => {
const startIndex = event.first;
const endIndex = event.first + this.rows;
const endIndex = Math.min(event.first + this.rows, this.state.totalRecords - 1);
const newProducts = startIndex === endIndex ? this.datasource.slice(startIndex) : this.datasource.slice(startIndex, endIndex);
this.setState({
first: startIndex,
products: this.datasource.slice(startIndex, endIndex),
products: newProducts,
loading: false
});
}, 1000);
Expand Down Expand Up @@ -362,18 +364,19 @@ const DataViewLazyDemo = () => {
setLoading(false);
});
}, 1000);
}
}, []); // eslint-disable-line react-hooks/exhaustive-deps
const onPage = (event) => {
setLoading(true);
//imitate delay of a backend call
setTimeout(() => {
const startIndex = event.first;
const endIndex = event.first + this.rows;
const endIndex = Math.min(event.first + this.rows, this.state.totalRecords - 1);
const newProducts = startIndex === endIndex ? datasource.slice(startIndex) : datasource.slice(startIndex, endIndex);
setFirst(startIndex);
setProducts(datasource.slice(startIndex, endIndex));
setProducts(newProducts);
setLoading(false);
}, 1000);
}
Expand Down Expand Up @@ -502,18 +505,19 @@ const DataViewLazyDemo = () => {
setLoading(false);
});
}, 1000);
}
}, []); // eslint-disable-line react-hooks/exhaustive-deps
const onPage = (event) => {
setLoading(true);
//imitate delay of a backend call
setTimeout(() => {
const startIndex = event.first;
const endIndex = event.first + this.rows;
const endIndex = Math.min(event.first + this.rows, this.state.totalRecords - 1);
const newProducts = startIndex === endIndex ? datasource.slice(startIndex) : datasource.slice(startIndex, endIndex);
setFirst(startIndex);
setProducts(datasource.slice(startIndex, endIndex));
setProducts(newProducts);
setLoading(false);
}, 1000);
}
Expand Down

0 comments on commit 49a26c7

Please sign in to comment.