I have two kendo sortable list, List A and List B. List A has fixed objects (item1, item2, item3) and list B is empty. Every time I drag an object from list A to list B, I want to be cloned into list B.

I noticed that if I try to drag the same item two or more times, it's always a copy of the same object listed in list A.

How can I drag the object from list A to list B cloning it?

Thank you

1

There are 1 answers

0
Marissa Fernandes On

I did have a go at your query of kendo sortable, but could not get any working code as the palette array is refreshed but i cannot get the sortable to refresh to show the updated data; however can you try something like this. When you move an item from A to B it is deleted from A and added to B, but can you prevent default and let A retain the item and add a new data item to B. I used the sortable Data add event

import { Component, ViewEncapsulation, Input } from '@angular/core';
import { DataEvent, DragStartEvent, DragEndEvent, DragOverEvent, NavigateEvent } from '@progress/kendo-angular-sortable';

@Component({
    selector: 'my-app',
    template: `
    <div class="example-config">
            <h5>Team A: {{palettes.TeamA | json}}</h5>
            <h5>Team B: {{palettes.TeamB | json}}</h5>
    </div>
    <div class="container-fluid">
        <div class="row">
            <div class="col-xs-12 col-sm-6 team">
                <h5>Team A</h5>
                <kendo-sortable
                    [kendoSortableBinding]="palettes.TeamA"
                    zone="twoWay"
                    emptyText="Move employees from Team B to Team A."
                    class="row"
                    itemClass="employee"
                    [emptyItemStyle]="{'min-height': '150px', width:'100%'}"
                    emptyItemClass="empty"
                    activeItemClass="employee active">
                </kendo-sortable>
            </div>
            <div class="col-xs-12 col-sm-6 team team-b">
                <h5>Team B</h5>
                <kendo-sortable [kendoSortableBinding]="palettes.TeamB"
                    zone="twoWay"
                    emptyText="Move employees from Team A to Team B."
                    class="row"
                    itemClass="employee"
                    [emptyItemStyle]="{'min-height': '150px', width:'100%'}"
                    emptyItemClass="empty"
                    activeItemClass="employee active"
                    (dataAdd)="onDataAdd('TeamA','TeamB', $event)">
                </kendo-sortable>
            </div>
        </div>
    </div>
`,
    styleUrls: ['styles.css'],
    encapsulation: ViewEncapsulation.None
})
export class AppComponent {
   @Input() textContent; 
    public palettes = {
        'TeamA': ['Peter Franken', 'Simon Crowther', 'Catherine Dewey','Lino Rodriguez', 'Paolo Accorti'],
        'TeamB': []
    };

  public onDataAdd(src: string, dest: string, e: any): void {
    e.preventDefault();
    this.palettes[dest].push(e.dataItem);   
  }
}