row-reordered
After rows have been reordered by the end user.
Please note - this property requires the RowReorder extension for DataTables.
Description
The event data is identical to the row-reorder
event. In comparison to the row-reorder
event, the event will be triggered after the row is dropped and after the data is updated.
This event is only triggered if the rowReorder.update
option has been enabled (which it is by default).
The data that has been changed by RowReorder is given in two different forms in the parameters for the event handler callback - one with detailed information about the individual rows, and one with data in a format suitable for Editor's multi-row editing feature.
Please note that, as with all DataTables emitted events, this event is triggered with the dt
namespace. As such, to listen for this event, you must also use the dt
namespace by simply appending .dt
to your event name, or use the on()
method to listen for the event which will automatically append this namespace.
Type
function function( e, details, edit )
- Parameters:
Name Type Optional 1 e
No jQuery event object
2 details
No An array of change objects for the row's how have had values effected. Each object contain the following properties:
Any
newData
- The new data value for the row (data point defined byrowReorder.dataSrc
)node
node
- Thetr
elementinteger
newPosition
- New index in the DOMAny
oldData
- The old data value for the rowinteger
oldPosition
- Old index in the DOM
3 edit
No This parameter provides the information required for Editor to perform a multi-row edit:
string
dataSrc
- Data point - typically the field to be edited (defined byrowReorder.dataSrc
)array
nodes
- The rows to be editedobject
values
- The new values in a format suitable formultiSet()
.DataTable.Api
triggerRow
(Since v1.1.0) - Row API instance for the row that was used to start the reorder (i.e. the result fromrow()
).
Example
Add a class to all changed rows:
var table = new DataTable('#myTable', {
rowReorder: true
});
table.on('row-reordered', function (e, diff, edit) {
for (var i = 0, ien = diff.length; i < ien; i++) {
$(diff[i].node).addClass('reordered');
}
});