Skip to content

Commit

Permalink
Merge branch 'dropdown-poc' of https://github.com/IgniteUI/igniteui-a…
Browse files Browse the repository at this point in the history
…ngular into dropdown-poc
  • Loading branch information
wnvko committed May 15, 2018
2 parents d51f929 + 521a7a3 commit 0e56f9d
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Ignite UI for Angular Change Log

All notable changes for each version of this project will be documented in this file.
## 6.0.0
- Added `onDoubleClick` output to `igxGrid` to emit the double clicked cell.
## 5.3.1
- igx-dialog changes
- Dialog title as well as dialog actions (buttons) can be customized. For more information navigate to the [ReadMe](https://github.com/IgniteUI/igniteui-angular/blob/master/src/dialog/README.md).
Expand Down
1 change: 1 addition & 0 deletions src/grid/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ A list of the events emitted by the **igx-grid**:
|`onColumnPinning`|Emitted when a column is pinned through the grid API. The index that the column is inserted at may be changed through the `insertAtIndex` property.|
|`onColumnResized`|Emitted when a column is resized. Returns the column object, previous and new column width.|
|`onContextMenu`|Emitted when a cell is right clicked. Returns the cell object.|
|`onDoubleClick`|Emitted when a cell is double clicked. Returns the cell object.|


Defining handlers for these event emitters is done using declarative event binding:
Expand Down
5 changes: 5 additions & 0 deletions src/grid/cell.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,11 @@ export class IgxGridCellComponent implements IGridBus, OnInit, OnDestroy {
if (this.column.editable) {
this.inEditMode = true;
}

this.grid.onDoubleClick.emit({
cell: this,
event
});
}

@HostListener("click", ["$event"])
Expand Down
31 changes: 30 additions & 1 deletion src/grid/cell.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, DebugElement, ViewChild } from "@angular/core";
import { async, TestBed } from "@angular/core/testing";
import { async, fakeAsync, TestBed } from "@angular/core/testing";
import { By } from "@angular/platform-browser";
import { take } from "rxjs/operators";
import { DataType } from "../data-operations/data-util";
Expand Down Expand Up @@ -202,6 +202,30 @@ describe("IgxGrid - Cell component", () => {
});
}));

it("Should trigger onDoubleClick event when double click into cell", async(() => {
const fix = TestBed.createComponent(DefaultGridComponent);
fix.detectChanges();

const grid = fix.componentInstance.instance;
const cellElem = fix.debugElement.query(By.css(CELL_CSS_CLASS));
const firstCell = grid.getCellByColumn(0, "index");

spyOn(grid.onDoubleClick, "emit").and.callThrough();
const event = new Event("dblclick");
cellElem.nativeElement.dispatchEvent(event);
const args: IGridCellEventArgs = {
cell: firstCell,
event
};

fix.whenStable().then(() => {
fix.detectChanges();

expect(grid.onDoubleClick.emit).toHaveBeenCalledWith(args);
expect(firstCell).toBe(fix.componentInstance.clickedCell);
});
}));

it("edit mode", async(() => {
const fix = TestBed.createComponent(DefaultGridComponent);
fix.detectChanges();
Expand Down Expand Up @@ -831,6 +855,7 @@ describe("IgxGrid - Cell component", () => {
(onSelection)="cellSelected($event)"
(onCellClick)="cellClick($event)"
(onContextMenu)="cellRightClick($event)"
(onDoubleClick)="doubleClick($event)"
[data]="data"
[autoGenerate]="true">
</igx-grid>
Expand Down Expand Up @@ -860,6 +885,10 @@ export class DefaultGridComponent {
public cellRightClick(evt) {
this.clickedCell = evt.cell;
}

public doubleClick(evt) {
this.clickedCell = evt.cell;
}
}

@Component({
Expand Down
3 changes: 3 additions & 0 deletions src/grid/grid.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,9 @@ export class IgxGridComponent implements OnInit, OnDestroy, AfterContentInit, Af
@Output()
public onContextMenu = new EventEmitter<IGridCellEventArgs>();

@Output()
public onDoubleClick = new EventEmitter<IGridCellEventArgs>();

@ContentChildren(IgxColumnComponent, { read: IgxColumnComponent })
public columnList: QueryList<IgxColumnComponent>;

Expand Down

0 comments on commit 0e56f9d

Please sign in to comment.