Skip to content

Commit

Permalink
Merge branch 'vNext' into mvenkov/add-row-selector-template-samples
Browse files Browse the repository at this point in the history
  • Loading branch information
wnvko authored Sep 10, 2019
2 parents c012c0c + 8b9c131 commit d03973c
Show file tree
Hide file tree
Showing 20 changed files with 28 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<igx-column [field]="'Fax'" [header]="'Fax'" width="100px"></igx-column>
</igx-grid>
<igx-grid #targetGrid igxDrop [data]="data2" [height]="'480px'" [width]="'640px'" [autoGenerate]="false" [emptyGridTemplate]="dragHereTemplate"
(onEnter)="onEnterAllowed($event)" (onLeave)="onLeaveAllowed($event)" (onDrop)="onDropAllowed($event)" [primaryKey]="'ID'">
(enter)="onEnterAllowed($event)" (leave)="onLeaveAllowed($event)" (dropped)="onDropAllowed($event)" [primaryKey]="'ID'">
<igx-column [field]="'ID'" [header]="'ID'" width="100px"></igx-column>
<igx-column [field]="'CompanyName'" [header]="'Company Name'" width="100px"></igx-column>
<igx-column [field]="'ContactName'" [header]="'Contact Name'" width="100px" [minWidth]="'60px'" [maxWidth]="'230px'"></igx-column>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,16 @@ export class GridDragBaseSampleComponent {
}

public onDropAllowed(args) {
args.cancel = true;
this.targetGrid.addRow(args.dragData.rowData);
this.sourceGrid.deleteRow(args.dragData.rowID);
}

public onEnterAllowed(args) {
this.changeGhostIcon(args.drag.dragGhost, DragIcon.ALLOW);
this.changeGhostIcon(args.drag.ghostElement, DragIcon.ALLOW);
}

public onLeaveAllowed(args) {
this.changeGhostIcon(args.drag.dragGhost, DragIcon.DEFAULT);
this.changeGhostIcon(args.drag.ghostElement, DragIcon.DEFAULT);
}

private changeGhostIcon(ghost, icon: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</ng-template>
</igx-grid>
<igx-grid #targetGrid igxDrop [data]="data2" [height]="'480px'" [width]="'640px'" [autoGenerate]="false" [emptyGridTemplate]="dragHereTemplate"
(onEnter)="onEnterAllowed($event)" (onLeave)="onLeaveAllowed($event)" (onDrop)="onDropAllowed($event)" [primaryKey]="'ID'">
(enter)="onEnterAllowed($event)" (leave)="onLeaveAllowed($event)" (dropped)="onDropAllowed($event)" [primaryKey]="'ID'">
<igx-column [field]="'ID'" [header]="'ID'" width="100px"></igx-column>
<igx-column [field]="'CompanyName'" [header]="'Company Name'" width="100px"></igx-column>
<igx-column [field]="'ContactName'" [header]="'Contact Name'" width="100px" [minWidth]="'60px'" [maxWidth]="'230px'"></igx-column>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,16 @@ export class GridDragToGridSampleComponent {
}

public onDropAllowed(args) {
args.cancel = true;
this.targetGrid.addRow(args.dragData.rowData);
this.sourceGrid.deleteRow(args.dragData.rowID);
}

public onEnterAllowed(args) {
this.changeGhostIcon(args.drag.dragGhost, DragIcon.ALLOW);
this.changeGhostIcon(args.drag.ghostElement, DragIcon.ALLOW);
}

public onLeaveAllowed(args) {
this.changeGhostIcon(args.drag.dragGhost, DragIcon.DEFAULT);
this.changeGhostIcon(args.drag.ghostElement, DragIcon.DEFAULT);
}

private changeGhostIcon(ghost, icon: string) {
Expand Down
2 changes: 1 addition & 1 deletion src/app/grid/grid-row-drag/grid-row-drag.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<div class="solar-system">
<div class="planets">
<planet #planet *ngFor="let data of planetData" [data]="data"
igxDrop (onEnter)="onEnter($event, planet)" (onLeave)="onLeave($event)" (onDrop)="onDrop($event, planet)"></planet>
igxDrop (enter)="onEnter($event, planet)" (leave)="onLeave($event)" (dropped)="onDrop($event, planet)"></planet>
</div>
<div class="sun-wrapper">
<div class="sun">
Expand Down
6 changes: 2 additions & 4 deletions src/app/grid/grid-row-drag/grid-row-drag.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ export class GridDragSampleComponent {
}

public onEnter(args, planet: PlanetComponent) {
args.drag.dragGhost.classList.add(
args.drag.ghostElement.classList.add(
this.isDropAllowed(args.dragData.rowData.name, planet.name) ? HoverClassList.ALLOW : HoverClassList.DENY);
}

public onLeave(args) {
const dragGhost: HTMLElement = args.drag.dragGhost;
const dragGhost: HTMLElement = args.drag.ghostElement;

if (dragGhost) {
dragGhost.classList.remove(HoverClassList.ALLOW);
Expand All @@ -49,8 +49,6 @@ export class GridDragSampleComponent {
}

public onDrop(args, planet: PlanetComponent) {
args.cancel = true;

const row: IgxRowComponent<IgxGridBaseComponent & IGridDataBindable> = args.dragData;
if (this.isDropAllowed(row.rowData.name, planet.name)) {
row.rowData.planet = planet.name;
Expand Down
2 changes: 1 addition & 1 deletion src/app/grid/grid-row-reorder-sample/grid-row-reorder.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="grid-container">
<igx-grid #grid [data]="data" [height]="'800px'" [width]="'1000px'" [autoGenerate]="false" [rowDraggable]="true"
[primaryKey]="'ID'" igxDrop (onDrop)="onDropAllowed($event)">
[primaryKey]="'ID'" igxDrop (dropped)="onDropAllowed($event)">
<igx-column [field]="'ID'" [header]="'ID'" width="100px"></igx-column>
<igx-column [field]="'CompanyName'" [header]="'Company Name'" width="100px"></igx-column>
<igx-column [field]="'ContactName'" [header]="'Contact Name'" width="100px" [minWidth]="'60px'"
Expand Down
1 change: 0 additions & 1 deletion src/app/grid/grid-row-reorder-sample/grid-row-reorder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export class GridRowReorderComponent {
}

public onDropAllowed(args) {
args.cancel = true;
const event = args.originalEvent;
const currRowIndex = this.getCurrentRowIndex(this.grid.rowList.toArray(),
{ x: event.pageX, y: event.pageY });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="drop-area" igxDrop (onEnter)="onEnterAllowed($event)" (onLeave)="onLeaveAllowed($event)"
(onDrop)="onDropAllowed($event)">
<div class="drop-area" igxDrop (enter)="onEnterAllowed($event)" (leave)="onLeaveAllowed($event)"
(dropped)="onDropAllowed($event)">
<igx-icon>delete</igx-icon>
<div>Drag a row here to delete it</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,16 @@ export class HGridRowDragBaseComponent {
}

public onDropAllowed(args: IDropDroppedEventArgs) {
args.cancel = true;
const draggedRow: IgxHierarchicalRowComponent = args.dragData;
draggedRow.delete();
}

public onEnterAllowed(args) {
this.changeGhostIcon(args.drag.dragGhost, DragIcon.ALLOW);
this.changeGhostIcon(args.drag.ghostElement, DragIcon.ALLOW);
}

public onLeaveAllowed(args) {
this.changeGhostIcon(args.drag.dragGhost, DragIcon.DEFAULT);
this.changeGhostIcon(args.drag.ghostElement, DragIcon.DEFAULT);
}

private changeGhostIcon(ghost, icon: string) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="drop-area" igxDrop (onEnter)="onEnterAllowed($event)" (onLeave)="onLeaveAllowed($event)"
(onDrop)="onDropAllowed($event)">
<div class="drop-area" igxDrop (enter)="onEnterAllowed($event)" (leave)="onLeaveAllowed($event)"
(dropped)="onDropAllowed($event)">
<igx-icon>delete</igx-icon>
<div>Drag a row here to delete it</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,16 @@ export class HGridDragSampleComponent {
}

public onDropAllowed(args: IDropDroppedEventArgs) {
args.cancel = true;
const draggedRow: IgxHierarchicalRowComponent = args.dragData;
draggedRow.delete();
}

public onEnterAllowed(args) {
this.changeGhostIcon(args.drag.dragGhost, DragIcon.ALLOW);
this.changeGhostIcon(args.drag.ghostElement, DragIcon.ALLOW);
}

public onLeaveAllowed(args) {
this.changeGhostIcon(args.drag.dragGhost, DragIcon.DEFAULT);
this.changeGhostIcon(args.drag.ghostElement, DragIcon.DEFAULT);
}

private changeGhostIcon(ghost, icon: string) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<igx-hierarchical-grid class="hgrid" igxDrop #grid1 [data]="localData" [primaryKey]="'id'"
[rowDraggable]="true" [rowSelectable]="true" (onRowDragStart)="rowDragStart($event)" (onDrop)="rowDrop($event)"
[rowDraggable]="true" [rowSelectable]="true" (onRowDragStart)="rowDragStart($event)" (dropped)="rowDrop($event)"
[height]="'540px'" [width]="'800px'" #hGrid>
<igx-column field="name" header="Name"></igx-column>
<igx-column field="system" header="Is System Drive"></igx-column>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export class HGridRowReorderComponent {
}

public rowDrop(args: IDropDroppedEventArgs): void {
args.cancel = true;
const targetRow = args.dragData;
const event = args.originalEvent;
const cursorPosition: Point = { x: event.pageX, y: event.pageY };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="drop-area" igxDrop (onEnter)="onEnterAllowed($event)" (onLeave)="onLeaveAllowed($event)"
(onDrop)="onDropAllowed($event)">
<div class="drop-area" igxDrop (enter)="onEnterAllowed($event)" (leave)="onLeaveAllowed($event)"
(dropped)="onDropAllowed($event)">
<igx-icon>delete</igx-icon>
<div>Drag a row here to delete it</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,16 @@ export class TreeGridRowDragBase {
}

public onDropAllowed(args: IDropDroppedEventArgs) {
args.cancel = true;
const draggedRow: IgxTreeGridRowComponent = args.dragData;
draggedRow.delete();
}

public onEnterAllowed(args) {
this.changeGhostIcon(args.drag.dragGhost, DragIcon.ALLOW);
this.changeGhostIcon(args.drag.ghostElement, DragIcon.ALLOW);
}

public onLeaveAllowed(args) {
this.changeGhostIcon(args.drag.dragGhost, DragIcon.DEFAULT);
this.changeGhostIcon(args.drag.ghostElement, DragIcon.DEFAULT);
}

private changeGhostIcon(ghost, icon: string) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="drop-area" igxDrop (onEnter)="onEnterAllowed($event)" (onLeave)="onLeaveAllowed($event)"
(onDrop)="onDropAllowed($event)">
<div class="drop-area" igxDrop (enter)="onEnterAllowed($event)" (leave)="onLeaveAllowed($event)"
(dropped)="onDropAllowed($event)">
<igx-icon>delete</igx-icon>
<div>Drag a row here to delete it</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,16 @@ export class TreeGridRowDrag {
}

public onDropAllowed(args: IDropDroppedEventArgs) {
args.cancel = true;
const draggedRow: IgxTreeGridRowComponent = args.dragData;
draggedRow.delete();
}

public onEnterAllowed(args) {
this.changeGhostIcon(args.drag.dragGhost, DragIcon.ALLOW);
this.changeGhostIcon(args.drag.ghostElement, DragIcon.ALLOW);
}

public onLeaveAllowed(args) {
this.changeGhostIcon(args.drag.dragGhost, DragIcon.DEFAULT);
this.changeGhostIcon(args.drag.ghostElement, DragIcon.DEFAULT);
}

private changeGhostIcon(ghost, icon: string) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="grid_wrapper">
<igx-tree-grid #treeGrid igxDrop [data]="localData" childDataKey="Employees" width="900px" height="550px"
[autoGenerate]="false" [rowDraggable]="true" [paging]="true" foreignKey="ParentID" [rowSelectable]="true"
[primaryKey]="'ID'" (onRowDragStart)="rowDragStart($event)" (onDrop)="dropInGrid($event)">
[primaryKey]="'ID'" (onRowDragStart)="rowDragStart($event)" (dropped)="dropInGrid($event)">
<igx-column field="Name" dataType="string" [sortable]="true" [editable]="true" [movable]="true"
[resizable]="true">
</igx-column>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export class TreeGridRowReorderComponent {
}

public dropInGrid(args: IDropDroppedEventArgs): void {
args.cancel = true;
const draggedRow: IgxTreeGridRowComponent = args.dragData;
const event = args.originalEvent;
const cursorPosition: Point = { x: event.pageX, y: event.pageY };
Expand Down

0 comments on commit d03973c

Please sign in to comment.