Skip to content

Commit

Permalink
Merge pull request #6973 from sammanan4/patch-1
Browse files Browse the repository at this point in the history
Fix rows reorder when pagination is applied.
  • Loading branch information
UtechtDustin authored Oct 1, 2023
2 parents 7160216 + bb7a329 commit ae57afd
Showing 1 changed file with 3 additions and 1 deletion.
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 = this.options.pageNumber
const pageSize = this.options.pageSize
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])

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

0 comments on commit ae57afd

Please sign in to comment.