Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(demo): out of boundaries page Grid Preset should be unset #347

Merged
merged 1 commit into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/examples/slickgrid/Example31.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ export default class Example31 extends React.Component<Props, State> {
}

// Read the result field from the JSON response.
const firstRow = skip;
let firstRow = skip;
let filteredData = data;
if (columnFilters) {
for (const columnId in columnFilters) {
Expand Down Expand Up @@ -366,6 +366,12 @@ export default class Example31 extends React.Component<Props, State> {
}
countTotalItems = filteredData.length;
}

// make sure page skip is not out of boundaries, if so reset to first page & remove skip from query
if (firstRow > filteredData.length) {
query = query.replace(`$skip=${firstRow}`, '');
firstRow = 0;
}
const updatedData = filteredData.slice(firstRow, firstRow + top!);

setTimeout(() => {
Expand Down
8 changes: 7 additions & 1 deletion src/examples/slickgrid/Example5.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ export default class Example5 extends React.Component<Props, State> {
}

// Read the result field from the JSON response.
const firstRow = skip;
let firstRow = skip;
let filteredData = data;
if (columnFilters) {
for (const columnId in columnFilters) {
Expand Down Expand Up @@ -375,6 +375,12 @@ export default class Example5 extends React.Component<Props, State> {
}
countTotalItems = filteredData.length;
}

// make sure page skip is not out of boundaries, if so reset to first page & remove skip from query
if (firstRow > filteredData.length) {
query = query.replace(`$skip=${firstRow}`, '');
firstRow = 0;
}
const updatedData = filteredData.slice(firstRow, firstRow + top!);

setTimeout(() => {
Expand Down