Bug in combination of rowreorder and rowgroup - Items sometimes appear at top of group after reorder
Bug in combination of rowreorder and rowgroup - Items sometimes appear at top of group after reorder
fprins
Posts: 3Questions: 0Answers: 0
When using rowreorder and rowgroup together sometimes when moving an item from one group to another the item doesn't end up at the position the item was dragged to but at the top of the group.
Probably related to https://datatables.net/forums/discussion/44263/possible-bug-combining-rowreorder-and-rowgroup
This discussion has been closed.
Replies
Hi @fprins ,
RowReorder is a funny one - if you drag it into a group, it may not stay within that group depending upon how the group is formed. For example, in this example here, groups are formed by the Office column - if you drop someone from London into the Edinburgh group, they won't stay there since the ordering means they need to belong with London.
Could you modify my example above to show the problem, please, and provide steps on how to reproduce it.
Cheers,
Colin
Hi @colin,
These problems can be reproduced on http://live.datatables.net/tavikoma/1/edit?html,js,console,output
Please let me know if I can help!
Regards, Jasper
You have
rowReorder.update
disabled so the table is not redrawn to reflect the reordering. This is ok depending on what you really want to do.The key with RowReorder is this from the
rowReorder.dataSrc
docs:Generally you will want this to be ordered. I updated your example to order first by the
rowGroup.dataSrc
then byrowReorder.dataSrc
. I commented outupdate: false,
so the table is automatically redrawn on each reorder.This results in not being able to move a row outside of its group. If you want the ability to move the rows into another group then that can be coded by using
update: false,
and therow-reorder
to update therowReorder.dataSrc
with the appropriate value.http://live.datatables.net/losomabo/1/edit
Does this help?
Kevin
@kthorngren, thanks for your detailed reply! I'm sorry for the confusion, I do know about
update: false
. I was fiddling with it without realizing it changes the content of the link I had already shared. I noticed this a few minutes after I posted the comment and quickly updated it with another link. That link does not include theupdate: false
part.Nevertheless, all issues I described can be reproduced in your example so no luck with that
Yes, you are right. There are some interesting things that happen with this combination. Will let @allan and @colin comment on your examples and any thoughts about making changes.
However, depending on what your requirements are, you could solve some of the problems with some custom code. One of the problems I see is the rows are reordered when dropping in a different group but this might be wanted. We could go with the approach of reverting back if trying to drop outside of the rowGroup. I took the last example in this thread and modified it to revert the rowReorder if the row is dropped outside the group.
http://live.datatables.net/losomabo/2/edit
It gets the group of the row being moved in the
pre-row-reorder
event then checks all the rows involved have the same group data. If not it will revert the row order.Kevin
@kthorngren, that's an interesting approach to disallow dragging to another group! I do want to allow dragging to a different group though.
N.B. I created a PR for the first issue I described: https://github.com/DataTables/RowReorder/pull/24
That will be an interesting piece of code to keep all the rows between the source and destination groups in order
Nice detail on your PRs!
Kevin
Thanks for the pull requests . I've merged them in now.
Allan
Thanks for your swift replies @allan! One issue down, two to go Although I'm afraid these are a little harder to tackle...