Skip to content

Commit

Permalink
Merge pull request #181 from toshiba/release/fix-change-page-size
Browse files Browse the repository at this point in the history
fix(Table): Fix change page size error when server pagination is not defined
  • Loading branch information
heliocastro authored Nov 30, 2023
2 parents 947545c + 9e471f4 commit e6fa710
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/components/sw360/Table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,15 @@ class Table extends Component<TableProps, unknown> {
private wrapper: RefObject<HTMLDivElement> = createRef()
// Grid.js instance
private readonly instance: Grid = null
private tableProps: TableProps = {}

constructor(props: TableProps) {
super(props)
let tableProps = { ...defaultOptions, ...props }
this.tableProps = { ...defaultOptions, ...props }

if (tableProps.server) {
tableProps = {
...tableProps,
if (this.tableProps.server) {
this.tableProps = {
...this.tableProps,
pagination: {
limit: 10,
server: {
Expand All @@ -52,7 +53,7 @@ class Table extends Component<TableProps, unknown> {
}
}

this.instance = new Grid(tableProps)
this.instance = new Grid(this.tableProps)
}

getInstance(): Grid {
Expand All @@ -79,10 +80,12 @@ class Table extends Component<TableProps, unknown> {
.updateConfig({
pagination: {
limit: pageSize,
server: {
url: (prev: string, page: number, limit: number) =>
`${prev}${prev.includes('?') ? '&' : '?'}page=${page}&page_entries=${limit}`,
},
server: this.tableProps.server
? {
url: (prev: string, page: number, limit: number) =>
`${prev}${prev.includes('?') ? '&' : '?'}page=${page}&page_entries=${limit}`,
}
: undefined,
},
})
.forceRender()
Expand Down

0 comments on commit e6fa710

Please sign in to comment.