简体   繁体   English

Angular ng-sortable - 如果我在一列中添加搜索框,则两列之间的拖放无法正常工作

[英]Angular ng-sortable - Drag drop not working properly between two columns if i add a search box in one cloumn

I am using the following library in my project.我在我的项目中使用以下库。

ng-sortable: https://github.com/a5hik/ng-sortable ng-sortable: https://github.com/a5hik/ng-sortable

In my scenario, I have 2 columns.在我的场景中,我有 2 列。 First column is with my data model and second column is empty.第一列是我的数据模型,第二列是空的。 I need to drag cells from first column and drop in 2nd(such that it gets cloned in second column).我需要从第一列拖动单元格并放入第二列(这样它就会被克隆到第二列中)。 All of this works fine but if i add a search box on top of my first column and filter results in my list based on search text, then drag drop gets screwed up.所有这些工作正常,但如果我在我的第一列顶部添加一个搜索框并根据搜索文本过滤我的列表中的结果,那么拖放就会被搞砸。 Incorrect items are getting dropped and cloned in 2nd column when i do drag from first column.当我从第一列拖动时,不正确的项目被丢弃并克隆到第二列。

Can somebody please tell me a fix for this?有人可以告诉我解决这个问题吗? Is this a bug in ng-sortable?这是 ng-sortable 中的错误吗? Is there any workaround/fix for this?是否有任何解决方法/修复方法?

<div as-sortable="sortoptions" data-ng-model="array"> <div><input type="text" ng-model="searchAttribute"></div> <div ng-repeat="item in array| filter:searchAttribute" as-sortable-item> <div as-sortable-item-handle> <div id="columns" class="list-group-item"> <span class="list-group-item-text">{{item}}</span> </div> </div> </div> </div>

I got this working.我得到了这个工作。 ng sortable expects the model to be updated in order to work properly. ng sortable 期望模型被更新以正常工作。 So instead of applying filter on view, it will work if filter is applied in controller on the model used in ng sortabl.因此,不是在视图上应用过滤器,而是将过滤器应用到控制器中用于 ng sortabl 的模型上。

[ https://github.com/a5hik/ng-sortable/issues/309][1] [ https://github.com/a5hik/ng-sortable/issues/309][1]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM