从<p-tree =“”>到<p-panel>拖放角度为5的primeng无效

时间:2018-08-17 11:54:24

标签: angular angular5 primeng

嘿,我陷入了严重的卡住,无法用primeng从p-tree拖到p-panel中。

我尝试了很多方法,但是没有任何效果。

请有人可以帮助我吗? :(

     <p-tree [value]="files" class="ui-helper-clearfix" 
            pDraggable="cars"
             (onDragStart)="dragStart($event,file)"
             (onDragEnd)="dragEnd($event)"
             [(selection)]="selectedNode"
             selectionMode="single"
             draggableNodes="true" 
             droppableNodes="true"
             (onNodeDrop)="onNodeDrop($event)"
             (onNodeSelect)="onNodeSelect($event)"
                  ></p-tree>

      <div pDroppable="pnl"  dragHandle=".ui-panel-titlebar">  <p-panel pDroppable="files" (onDrop)="drop($event)">
            <div>
                {{selectedTable}}
            </div>
        </p-panel>
        </div>

  public dragStart(event,table: TreeNode) {
        this.draggedTable = table;
    }

    public drop(event) {
        if(this.draggedTable) {
            let draggedTableIndex = this.findIndex(this.draggedTable);
            this.selectedTable = [...this.selectedTable, this.draggedTable];
            this.files = this.files.filter((val,i) => i!=draggedTableIndex);
            this.draggedTable = null;
        }
    }

    public dragEnd(event) {
        this.draggedTable = null;
    }
    public findIndex(node: TreeNode) {
        let index = -1;
        for(let i = 0; i < this.files.length; i++) {
            if(node.label === this.files[i]) {
                index = i;
                break;
            }
        }
        return index;
    }

0 个答案:

没有答案