ngx-sortablejs icon indicating copy to clipboard operation
ngx-sortablejs copied to clipboard

How to lock any item on its position?

Open Prontsevich opened this issue 8 years ago • 7 comments

Hello!

I use you lib for grouping items in a list. On each item I have switcher - when it's ON group creates and this item must be the first in that group. But when I drag new item onto this group I can put it higher then the first item and replace it with new, that's wrong. How can I do that all new items can only be added below the first one in the group?

Prontsevich avatar Jan 23 '18 11:01 Prontsevich

Please check the original library's group.put option / property https://github.com/RubaXa/Sortable#group-option. You should use function to decide whether to allow / disallow the adding

smnbbrv avatar Jan 23 '18 12:01 smnbbrv

Thank you for your answer, but it's not what I need. I'll show you some screenshots, maybe that helps to explain what I want. This is our grid with tickets. We can group tickets into a block. There is a switcher button on each item, when we switch it ON we create a new block (drop place) and this item must always be the first in it. general view

When I'm dragging any free item into a new block I can see ghost element - the place where to put new item. Now this ghost item can be above the first item in the block and will replace it after drop. That's what I don't want. incorrect

I need all newly pushed elements to be added below the first element and ghost element can be placed only below the first item. Even if I drag it above the first item. correct

So how can I lock the first item?

Prontsevich avatar Jan 23 '18 16:01 Prontsevich

Hi @Prontsevich

the block line itself is not a part that needs to be sorted, right?

From my prospective, in your particular case, it is way better to split the whole thing to have a sortable directive for each of the block (and each of the block lines should be above them).

Then, connect the sortable directives using the group option like it is done here https://smnbbrv.github.io/angular-sortablejs-demo/multiple-lists

The fact that it's a table is making it harder I guess but I have no better ideas. Either it could be done by splitting or by group property with a custom function.

smnbbrv avatar Jan 23 '18 19:01 smnbbrv

answered, no more activity => closing

smnbbrv avatar Feb 16 '18 16:02 smnbbrv

I am looking into the above example (https://smnbbrv.github.io/angular-sortablejs-demo/multiple-lists). When you start dragging element 4 upwards (very slowly), it becomes sensitive and change position of element 2. Again it becomes normal and only changes element 3. So why is this happening when we start dragging any element. I have seen this behavior on multiple examples. Any solution?

gsinha avatar Aug 07 '18 09:08 gsinha

Is there any way we can lock an item at the last position?

anuragsx avatar Sep 06 '18 16:09 anuragsx

I have disabled dragging on a certain element in the list but as explained by @gsinha I am also facing similar issue. Did anyone get the solution for it?

itsmenayan avatar May 15 '20 18:05 itsmenayan