Skip to content

Commit

Permalink
Merge pull request #12 from ghiscoding/bugfix/invalid-pagination-preset
Browse files Browse the repository at this point in the history
fix(demo): out of boundaries page Grid Preset should be unset
  • Loading branch information
ghiscoding authored May 23, 2024
2 parents 136637b + 6d08e67 commit 34754b9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion bootstrap5-i18n-demo/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 bootstrap5-i18n-demo/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

0 comments on commit 34754b9

Please sign in to comment.