PrimeNG PickList onMove and onMoveAll event handlers

UI Components for Angular
Post Reply
ctran2428
Posts: 39
Joined: 27 Apr 2017, 04:15

17 Nov 2017, 18:30

I am using PrimeNG PickList (5.0.0-rc0) for my Angular 5 application. My problem is that `onMoveToTarget` and `onMoveAllToTarget` get called simultaneously which I do not think it should behave like that. I use the PickList to dynamically add `FormControl` to my `Form` based on what is/are picked.

Use case:

Code: Select all

	moveAllToTarget: boolean = false; <-- I default the boolean to false.

Code: Select all

    onMoveToTargetHandler(event) {
      if (!this.moveAllToTarget) { <-- this still gets called even if I hit "Select All" button on the PickList. This is probably because this gets called regardless of "Move To Target" or "Move All To Target" buttons. Hence, at this point, my boolean is still false.
        this.form.addControl(event.items[0].slug, this._formBuilder.group({//some model that matches the control added}))
      }
    }

Code: Select all

    onMoveAllToTargetHandler(event) {
      this.moveAllToTarget = true;
      let itemsProcessed = 0;
      event.items.forEach(item => {
       this.form.addControl(item.slug, this._formBuilder.group({//some model that matches the control added}));
       itemsProcessed++;
      });
      if (itemsProcessed === event.items.length) {
       this.moveAllToTarget = false;
      }
    }

These two methods get called like almost simultaneously which causes me to have duplicated `FormControls` in my form.
Note: This is the exact copy of my question on StackOverflow. If you ever stumble upon that, feel free to answer there as well. Thanks

Is there a way to get around this? I thought I'd ask here before submitting an issue to PrimeNG Github.

Noti

ctran2428
Posts: 39
Joined: 27 Apr 2017, 04:15

19 Nov 2017, 18:27

I'm still in need of an answer/suggestion for this.
UP

ctran2428
Posts: 39
Joined: 27 Apr 2017, 04:15

20 Nov 2017, 20:40

Just a quick bump as I am still in need of a suggestion for this. Currently have to hide Select All and Remove All buttons

ctran2428
Posts: 39
Joined: 27 Apr 2017, 04:15

22 Nov 2017, 16:59

Still in need of suggestion for this one.

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 4 guests