Row-reorder: Row keeps flipping back on mousedown
Row-reorder: Row keeps flipping back on mousedown
Hello,
i have an issue with the row-reorder part of the software. it just does not work for me. I saw it working but without doing any essential changes to the code it stopped working for me. i can drag the item of my table which works absolutely fine, but as soon as i drop them everything flips back into the old order. Does anyone have the same issue or knows how to solve this? I have tried all possible options i could have thought of, none of which worked, obviously.
Thanks in advance for your help,
greetings
Stephan
Debug-Code: adumoh
$(document).ready(function () {
var DataTable = $("#ConfigMenuTable").DataTable({
data: data,
columns: [
{data: 'positionY'},
{data: 'Label'},
{data: 'id'},
{data: 'visible'}
],
paging: false,
info: false,
searching: false,
language: lango,
rowReorder: {
selector: 'tr'
}
});
});
EDIT:
I have found a solution to this problem, but it is strange. If i configure the dataSrc parameter wrongfully it starts working.
for instance with:
dataSrc: 'Label.id.visible'
it is working like a charm, although console says the following:
Uncaught TypeError: Cannot assign to read only property 'id' of Werkstatt-Teams
Anyone any idea on that?
Answers
Im guessing the issue withbit being read only, is DT has to be able to write to it when it reords the rows. Can you make a live.datatables.net instance? Or link to the page using datatables
Yes, I'd be interesting in taking a look at a test case to see why this is happening.
Thanks,
Allan
Here is the fiddle with the code.
https://jsfiddle.net/k7d68xvb/1/
As you can see, dragging works, dropping not so well.
An interesting fact: When the DataSrc-Parameter for a column is set, it makes the column work as desired. So the behaviour is kind of inverted here?!
You need to set the
rowReorder.dataSrc
option if you are using objects. If you don't then RowReorder doesn't known (and can't know) what property it should update when you swap the row ordering.Allan
Using this parameter doesn't fix the problem
https://jsfiddle.net/k7d68xvb/4/
Did i apply it incorrectly? I followed the documentation here....
The problem there is that it is still sorting but the first column - which just contains the value
1
. And since DataTables does a stable sort, yes, it retains the position.You'd need to use a sequential number - https://jsfiddle.net/k7d68xvb/5/ .
Allan