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

Increment totalRows and pageSize on row insertion in server mode #7312

Closed
wants to merge 5 commits into from
Closed
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
29 changes: 19 additions & 10 deletions src/bootstrap-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -1980,6 +1980,11 @@ class BootstrapTable {
params.sortName = this.header.sortNames[index]
}

if (this.options.hasOwnProperty("backUpPageSizeServer")) {
this.options.pageSize = this.options.backUpPageSizeServer // reset pageSize
delete this.options.backUpPageSizeServer
}

if (this.options.pagination && this.options.sidePagination === 'server') {
params.pageSize = this.options.pageSize === this.options.formatAllRows() ?
this.options.totalRows : this.options.pageSize
Expand Down Expand Up @@ -2594,11 +2599,7 @@ class BootstrapTable {
return
}

if (this.options.sidePagination === 'server') {
this.options.totalRows -= removed
this.data = [...this.options.data]
}

this.updateServerPagination(-removed)
this.initSearch()
this.initPagination()
this.initSort()
Expand All @@ -2619,6 +2620,7 @@ class BootstrapTable {
return
}
this.options.data.splice(params.index, 0, params.row)
this.updateServerPagination(1)
this.initSearch()
this.initPagination()
this.initSort()
Expand Down Expand Up @@ -2722,11 +2724,7 @@ class BootstrapTable {
return
}

if (this.options.sidePagination === 'server') {
this.options.totalRows -= 1
this.data = [...this.options.data]
}

this.updateServerPagination(-1)
this.initSearch()
this.initPagination()
this.initBody(true)
Expand Down Expand Up @@ -3434,6 +3432,17 @@ class BootstrapTable {
this.initPagination()
this.initBody()
}

updateServerPagination (rowChange) {
if (this.options.sidePagination === 'server') {
this.options.totalRows += rowChange
if (!this.options.hasOwnProperty("backUpPageSizeServer")) {
this.options.backUpPageSizeServer = this.options.pageSize
}
this.options.pageSize += rowChange
this.data = [...this.options.data]
}
}
}

BootstrapTable.VERSION = Constants.VERSION
Expand Down