wenzhixin / bootstrap-table

An extended table to integration with some of the most widely used CSS frameworks. (Supports Bootstrap, Semantic UI, Bulma, Material Design, Foundation, Vue.js)
https://bootstrap-table.com/
MIT License
11.74k stars 4.44k forks source link

Reorder Rows Example Does Not Show Ordered Data on getData Button #7618

Open neilskilling-overskilling opened 1 week ago

neilskilling-overskilling commented 1 week ago

Bootstraptable version(s) affected

1.23.5

Description

I am trying to get the onReorderRow event to fire and so I have gone back to the Reorder Rows example to see what I am doing wrong.

When I run the example and move a row around the getData alert just shows the ids in the original order. I thought that the idea of this example was to reorder the ids?

Also would be possible to add an example of onReorderRows event to this example as I can't get that to do anything. It may be related to the above issue.

I have tried changing line 28 to this:

$('#table').bootstrapTable({
            onReorderRow: function(arg1, arg2, arg3) {
               console.log(arg1, arg2, arg3)
           }
    }))

But it never gets called. I have three arguments here - the documentation states there are two arguments but lists three:

https://bootstrap-table.com/docs/extensions/reorder-rows/

Example(s)

https://live.bootstrap-table.com/example/extensions/reorder-rows.html is the original example

I copied that code to my own example: https://live.bootstrap-table.com/code/neilskilling-overskilling/18369 but this is just the same as the real example.

Possible Solutions

No response

Additional Context

No response

borkowskizbigniew commented 1 week ago

I had the same problem and after a few hours of searching I found the problem in the bootstrap-table.js code in the "initRow" method. Since version > 1.23.2 there have been changes that prevent rows reordering from working correctly. I changed one line of code in "bootstrap-table/src/bootstrap-table.js:1536", namely from "id: Array.isArray(item) ? undefined : item._id," to "id: attributes.id || (Array.isArray(item) ? undefined : item._id), and rows reordering works again.