【发布时间】:2015-03-31 18:08:39
【问题描述】:
我想使用 kendo ui 可排序列表视图从绑定对象中获取排序列表项。请参考下面的示例代码。
【问题讨论】:
-
你在这里要求什么?您已经在排序列表视图中拥有所有项目。您是否尝试保存列表的新顺序?
-
是的..我想保存新的订单列表。
标签: kendo-ui angularjs-ng-repeat kendo-sortable
我想使用 kendo ui 可排序列表视图从绑定对象中获取排序列表项。请参考下面的示例代码。
【问题讨论】:
标签: kendo-ui angularjs-ng-repeat kendo-sortable
一种方法是使用在可排序列表的移动或更改时触发的 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,关于使用带角度的事件,以及他们声称的最佳实践。希望对您有所帮助!
【讨论】: