ng2-dnd icon indicating copy to clipboard operation
ng2-dnd copied to clipboard

Save new order of a simple list.

Open alfakappa opened this issue 8 years ago • 4 comments

  • I'm submitting a ... [ ] bug report [x ] feature request [ ] question about the decisions made in the repository

  • Do you want to request a feature or report a bug? Probably this is already available; but I want to "save" the new order of my list...

  • What is the current behavior? I tried something with dragData, but I'm not sure which event of property to call.

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://plnkr.co or similar.

  • What is the expected behavior?

  • What is the motivation / use case for changing the behavior?

  • Please tell us about your environment:

  • Angular version: 2.X.X
  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc)

alfakappa avatar Jan 19 '17 15:01 alfakappa

as a workaround i put my item id in an hidden input field, and i get the new order with this

private getFlowOrder(): number[] {
  let t = document.querySelectorAll('#mySortableList #itemId');
  let newOrder: number[] = [];
  for (let i = 0; i <= t.length; i++) {
    if (t.item(i) !== null)
      newOrder.push((t.item(i) as any).value);
  }
  return newOrder;
}

ildoc avatar Feb 10 '17 08:02 ildoc

@ildoc I have this same issue...I have something like this:

<ul *ngIf="taskItems" class="tasks" dnd-sortable-container [sortableData]="taskItems">
        <li *ngFor="let task of taskItems; let i = index" dnd-sortable [sortableIndex]="i" (onDropSuccess)="dropSuccess($item)">
          <task-item
            class="task-item"
            [task]="task" 
            (remove)="removeTaskItem.emit(task)" 
            (update)="updateTaskItem.emit({task: task, changes: $event})">
          </task-item>
        </li>
      </ul>

Where each task object has a "sortedIndex" value that I'd like to update and keep in sync with whatever list position it's in.

Also, could I get it to work with an orderBy pipe? I was having trouble when trying earlier (the items wouldn't drop in place).

nick-jonas avatar Mar 16 '17 02:03 nick-jonas

Any supported solution for this issue?

ClaytonBrawley avatar Oct 06 '17 20:10 ClaytonBrawley

UP

Jerome2606 avatar Jun 05 '19 14:06 Jerome2606