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

955 Views Asked by At

I am using the following library in my project.

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

In my scenario, I have 2 columns. 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? 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>

1

There are 1 best solutions below

0
On

I got this working. ng sortable expects the model to be updated in order to work properly. So instead of applying filter on view, it will work if filter is applied in controller on the model used in ng sortabl.

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