簡體   English   中英

如何實現兩個劍道可排序對象:一個帶有固定元素(調色板對象),另一個帶有每個元素的副本

[英]How to implement two kendo sortable: one with fixed elements (palette objects) and the other with copies of each element dropped

我有兩個kendo可排序列表,列表A和列表B。列表A具有固定的對象(item1,item2,item3),列表B為空。 每次將對象從列表A拖動到列表B時,我都希望將其克隆到列表B中。

我注意到,如果我嘗試將同一項目拖兩次或多次,則它始終是列表A中列出的同一對象的副本。

如何將對象從列表A拖到列表B進行克隆?

謝謝

我確實對kendo sortable進行了查詢,但是由於刷新了調色板數組,因此無法獲得任何有效的代碼,但是我無法通過sortable刷新以顯示更新的數據。 但是你可以嘗試這樣的事情。 當您將項目從A移到B時,它會從A刪除並添加到B,但是可以防止默認設置,讓A保留該項目並將新的數據項添加到B。我使用了sortable Data add事件

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);   
  }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM