row-reorder event not fired
row-reorder event not fired
I have generated a datatable using the latest release Datatables 1.10.15 along with the latest of all the extensions. Row reorder is functioning, however I want to update the ordering back to the server. Unfortunately the row-reorder event never gets called. Here is the code:
var table = $(tableId).dataTable({
ajax: url,
columns: [
{ data: 'SortIndex', className: 'reorder' },
{ data: 'MeasureId' },
{ data: 'MeasureGroup', "className": "text-right" },
{ data: 'Type', "className": "text-left" },
{ data: 'Display', "className": "text-left kitt-truncate" },
{ data: 'Location', "className": "text-left kitt-truncate" },
{ data: 'Status', "className": "text-left" },
{ data: 'ActualQuantity', "className": "text-right" },
{ data: 'CostPerUnit', "className": "text-right" },
{ data: 'CustomerIncentive', "className": "text-right" },
{ data: 'EnergyDeltaKwh', "className": "text-right" },
{ data: 'SummerLoadReduction', "className": "text-right" },
{ data: 'WinterLoadReduction', "className": "text-right" },
{ data: 'FuelDeltaMmbtu', "className": "text-right" },
{
data: 'CanScreen',
"className": "text-center"
}
],
"sAjaxDataProp": "",
rowReorder: true,
dataSrc: "",
"bPaginate": false
});
table.on('row-reorder', function (e, details, changes) {
alert("hello");
});
I have also tried it using editor with example on this page:
https://datatables.net/reference/event/row-reorder
and that returns with this: Uncaught TypeError: Cannot read property 'multiSet' of undefined
Thanks!
Answers
Instead of this:
Maybe you need to do something like this:
You may need to define that field in the Editor also.
Kevin
Hi,
Change:
to be:
The difference is that the
DataTable()
returns an API instance, rather than a jQuery object (whichdataTable()
does).Its a bit iccky, but both DataTables and jQuery have
on()
methods, which is why you won't get any Javascript errors. But with DataTables'on()
method it will automatically listen for events in the DataTables namespace, where as for jQuery's method you need to userow-reorder.dt
.What Kevin mentioned I don't think will resolve your issue as such, but it is a valid point - there is no
dataSrc
option at the bottom level of the DataTables configuration.There is
ajax.dataSrc
androwReorder.dataSrc
. There is a good chance you will need to define both (and remove the legacysAjaxDataProp
).Regards,
Allan
Allan,
That fixed it! Thanks Kevn. I had tried playing with dataSrc but obviously had no impact as I had a key ingredient missing.
Tim