a5hik / ng-sortable

AngularJS Library for Drag and Drop, supports Sortable and Draggable. Supports Touch devices.
http://a5hik.github.io/ng-sortable/
MIT License
1.15k stars 314 forks source link

Nested sortable #15

Closed minhtranite closed 10 years ago

minhtranite commented 10 years ago

Hi guys! How to make 'ng-sortable' work with nested sortable or disable inner sortable.

a5hik commented 10 years ago

Hi you may want to have a look at http://ngmodules.org/modules/angular-ui-tree

minhtranite commented 10 years ago

I know angular-ui-tree but that is not what I need. You can watch a video recording of my screen to understand more of what I need. Thanks! http://youtu.be/LVq8YwqdMdk

a5hik commented 10 years ago

Hi If I'm not wrong what you are trying is to do Sorting with in another sorting . This should be doable. Please try with Isolate scope.

minhtranite commented 10 years ago

You can see example code here http://plnkr.co/edit/GOKSHr. Please make it run.(Keep use "two way binding" for items).

g-perrot commented 10 years ago

This might be late, but I needed to do nested sortables in my current project, and this is how I did it :
http://plnkr.co/edit/LtQueIa0llGOKYyS4lWX?p=preview.

maximeg commented 10 years ago

I confirm this is working fine. You can close this.

minhtranite commented 10 years ago

Thank!

butaixianran commented 9 years ago

Here is a solution, without angular-ui-tree.

Actually ng-sortable supports nested data very well, the problem is: as-sortable-item-handle doesn't.

So, the really problem is: element with "as-sortable-item-handle" can't be the container of "as-sortable" and "as-sortable-item".

Then the solution is simple: Set a title bar for all the nodes you want to drag. And set as-sortable-item-handle on this title bar. Like this:

<div this-is-level-1>
    <div>title bar</div>
    <div this-is-level-2>
        <div>title bar</div>
        <div this-is-level-3>
         .....
        </div>
    </div>
</div>

In this way, no matter how many levels your nested data has, your as-sortable and as-sortable-item will never be under an "as-sortable-item-handle "