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 rows reorder when pagination is applied. #6973

Merged
merged 5 commits into from
Oct 1, 2023
Merged
Changes from 1 commit
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
4 changes: 3 additions & 1 deletion src/extensions/reorder-rows/bootstrap-table-reorder-rows.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ $.BootstrapTable = class extends $.BootstrapTable {

onDrop (table) {
this.$draggingTd.css('cursor', '')
const pageNum = $(table).bootstrapTable('getOptions').pageNumber;
const pageSize = $(table).bootstrapTable('getOptions').pageSize;
sammanan4 marked this conversation as resolved.
Show resolved Hide resolved
const newData = []

for (let i = 0; i < table.tBodies[0].rows.length; i++) {
Expand All @@ -109,7 +111,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
const draggingRow = this.data[this.draggingIndex]
const droppedIndex = newData.indexOf(this.data[this.draggingIndex])
const droppedRow = this.data[droppedIndex]
const index = this.options.data.indexOf(this.data[droppedIndex])
const index = ((pageNum - 1)*pageSize) + this.options.data.indexOf(this.data[droppedIndex])
sammanan4 marked this conversation as resolved.
Show resolved Hide resolved

this.options.data.splice(this.options.data.indexOf(draggingRow), 1)
this.options.data.splice(index, 0, draggingRow)
Expand Down