如何从 kendo ui sortable 获取项目列表

How to get item list from kendo ui sortable

我想使用 kendo ui 可排序列表视图从绑定对象中获取排序列表项。请参考下面的示例代码。

http://dojo.telerik.com/@lilan123/eWofa/2

一种方法是使用在移动或更改可排序列表时触发的 Kendo 事件来设置移动的 ng-repeat 中项目的新索引值。

您在 "k-on-change" 中设置了事件。

<ol id="sortable" kendo-sortable k-options="sortableOptions" k-on-change="change(kendoEvent)">

然后将事件添加到范围。

$scope.change = function(e) {
  console.log(e);
  alert("The e object has stuff like the old index:" + e.oldIndex);
  //Get the correct item from the bound list based on index and change the index values in the list to match.       
}

这似乎是一个 hack,但话又说回来,在使用 Telerik 控件时总是感觉像一个 hack。

这里有一个很好的 blog post 将事件与 angular 一起使用,他们声称这是最佳实践。希望对您有所帮助!