I am trying to add row reordering functionality inkendoTreeList using kendoSortable using following code.
var grid =$('#scorecardTreeList').kendoTreeList({
dataSource: treedataSource,
columns: [
{ field: "strategicName", title: "Strategic Name" },
{ field: "Type", title: "Type" },
{ field: "Name", title: "Name" }
],
selectable: true,
expanded: true
}).data("kendoTreeList");
$($('#scorecardTreeList table')[1]).kendoSortable({
filter: ">tbody >tr",
hint: $.noop,
cursor: "move",
placeholder: function(element) {
return element.clone().addClass("k-state-hover").css("opacity", 0.65);
},
container: "#scorecardTreeList tbody",
change: function(e) {
var skip =0,
oldIndex = e.oldIndex + skip,
newIndex = e.newIndex + skip,
data = treedataSource.data(),
dataItem = treedataSource.getByUid(e.item.data("uid"));
grid.dataSource.remove(dataItem);
grid.dataSource.insert(newIndex, dataItem);
}
});
I am facing issue that the row next to desired row (which i want to move) appears below dragged row after reordering.
e.g if I have following rows
Tiger
Apple
Meow
Orange
ABC1
when I move Tiger below Orange the new order appears as
Meow
Orange
Tiger
Apple
ABC1 which is unexpected.
Please help.
var grid =$('#scorecardTreeList').kendoTreeList({
dataSource: treedataSource,
columns: [
{ field: "strategicName", title: "Strategic Name" },
{ field: "Type", title: "Type" },
{ field: "Name", title: "Name" }
],
selectable: true,
expanded: true
}).data("kendoTreeList");
$($('#scorecardTreeList table')[1]).kendoSortable({
filter: ">tbody >tr",
hint: $.noop,
cursor: "move",
placeholder: function(element) {
return element.clone().addClass("k-state-hover").css("opacity", 0.65);
},
container: "#scorecardTreeList tbody",
change: function(e) {
var skip =0,
oldIndex = e.oldIndex + skip,
newIndex = e.newIndex + skip,
data = treedataSource.data(),
dataItem = treedataSource.getByUid(e.item.data("uid"));
grid.dataSource.remove(dataItem);
grid.dataSource.insert(newIndex, dataItem);
}
});
I am facing issue that the row next to desired row (which i want to move) appears below dragged row after reordering.
e.g if I have following rows
Tiger
Apple
Meow
Orange
ABC1
when I move Tiger below Orange the new order appears as
Meow
Orange
Tiger
Apple
ABC1 which is unexpected.
Please help.