【问题标题】:How to get item list from kendo ui sortable如何从可排序的剑道 ui 中获取项目列表
【发布时间】:2015-03-31 18:08:39
【问题描述】:

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

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

【问题讨论】:

  • 你在这里要求什么?您已经在排序列表视图中拥有所有项目。您是否尝试保存列表的新顺序?
  • 是的..我想保存新的订单列表。

标签: kendo-ui angularjs-ng-repeat kendo-sortable


【解决方案1】:

一种方法是使用在可排序列表的移动或更改时触发的 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,关于使用带角度的事件,以及他们声称的最佳实践。希望对您有所帮助!

【讨论】:

  • 是的,我是这样做的,但我觉得不是有角度的做事方式。 $scope.onChange = function(e) { var item = activePriest.splice(e.oldIndex, 1)[0]; activePriest.splice(e.newIndex, 0, item); };我们可以在剑道中做到这一点吗?
  • 这很困难,因为您将角度列表的顺序基于项目本身的索引,这很棒。但是当你移动它时,你还必须修改索引的对象值,并修改其他每个项目中的索引值。另一个困难的方面是,因为它是一个 Telerik 控件,所以您实际上并没有处理绑定的元素。它们具有各种“魔法”,因此您可以从视觉上获得想要的东西,但是您可能无法选择“角度方式”,因为您使用的是剑道。这是一种“剑道角度”的方式。
  • 有什么方法可以重置排序列表?
  • 我不确定,但似乎刷新数据会起作用。比如... $("#sortable").data('kendoSortable').refresh();
猜你喜欢
  • 1970-01-01
  • 2015-02-09
  • 2014-04-28
  • 1970-01-01
  • 1970-01-01
  • 2017-04-08
  • 1970-01-01
  • 2015-11-24
  • 2013-07-14
相关资源
最近更新 更多