ordered list change

UI Components for Angular
mthor1979
Posts: 79
Joined: 03 Mar 2016, 07:26

09 Nov 2016, 15:26

onReorder(event: any, data: any) {
for (var i = 0; i < this.speeddials.length; i++) {
this.speeddials.speedDialIndex = i + 1;
}
}


this is how I use it and change a column value that show the order after it is reOrdered.

bohms27
Posts: 7
Joined: 19 May 2016, 16:15

09 Nov 2016, 16:58

That makes sense, but I need to know which item was selected to be changed, so I can find where it's old position in the array was versus it's new position in the array.

For example, I have an API that expects the original index and a shift value. So if I reorder index 0 to go to index 1, the shift value would be 1. If I'm using the move up one / move down one functionality this is simple, but when it gets to moving an item from the bottom of the list to the top, that gets dicey.

sourav_patra
Posts: 4
Joined: 12 Apr 2018, 14:32

14 Nov 2018, 08:01

Currently, the ordered list supports selection of multiple items (if we press ctrl and select the list items, they get selected. If we don't then the list items selected are toggled) Is there a way we can disable this 'multi selection of items' altogether? Not even on pressing the meta key 'ctrl'. I need to be able to select ONE item ALWAYS. Thanks

hamidh2
Posts: 4
Joined: 19 Jul 2021, 15:12

19 Jul 2021, 16:15

mthor1979 wrote:
09 Nov 2016, 15:26
onReorder(event: any, data: any) {
for (var i = 0; i < this.speeddials.length; i++) {
this.speeddials.speedDialIndex = i + 1;
}
}


this is how I use it and change a column value that shows the order after it is reOrdered.


Would you share your template(HTML file )? I want to know how u call the OnReorderMethod with those two parameters because data is not possible in that scope!!

Code: Select all

    <p-orderList
              [value]="categoryList"
              class="font-size-lg"
              [dragdrop]="true"
              (onReorder)="handleReorderingItem($event)"
            >
              <ng-template let-item pTemplate="item">
How is possible to pass both event and item to handleReorderingItem method whearase item is not defined in that scope!!
btw in current state handleReorderingItem($event) only pass selected item data as parameter since I want to get orderIndex how can I do that?

Post Reply

Return to “PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: Google [Bot] and 13 guests