Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add row double click option #168

Merged
merged 1 commit into from
Oct 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/components/body/body.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import { Subscription } from 'rxjs/Subscription';
import { Keys, selectRows, selectRowsBetween, translateXY } from '../../utils';
import { StateService } from '../../services';
import { SelectionType } from '../../types';
import { SelectionType, ClickType } from '../../types';
import { Scroller } from '../../directives';

@Component({
Expand All @@ -38,6 +38,7 @@ import { Scroller } from '../../directives';
*ngFor="let row of rows; let i = index; trackBy: trackRowBy"
[attr.tabindex]="i"
(click)="rowClicked($event, i, row)"
(dblclick)="rowClicked($event, i, row)"
(keydown)="rowKeydown($event, i, row)"
[row]="row"
[class.datatable-row-even]="row.$$index % 2 === 0"
Expand Down Expand Up @@ -190,7 +191,8 @@ export class DataTableBody implements OnInit, OnDestroy {
}

rowClicked(event, index, row): void {
this.onRowClick.emit({event, row});
let clickType = event.type === 'dblclick' ? ClickType.double : ClickType.single;
this.onRowClick.emit({ type: clickType, event, row });
this.selectRow(event, index, row);
}

Expand Down
4 changes: 4 additions & 0 deletions src/demos/virtual.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import '../themes/material.scss';
class='material'
[rows]='rows'
(onPageChange)="paged($event)"
(onRowClick)="rowClick($event)"
[options]='options'>

<datatable-column name="Name">
Expand Down Expand Up @@ -71,4 +72,7 @@ export class App {
req.send();
}

rowClick(args) {
console.log('rowClick', args);
}
}
4 changes: 4 additions & 0 deletions src/types/click.type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export enum ClickType {
single = 'single' as any,
double = 'double' as any
}
1 change: 1 addition & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export * from './column-mode.type';
export * from './sort.type';
export * from './sort-direction.type';
export * from './selection.type';
export * from './click.type';