-
Notifications
You must be signed in to change notification settings - Fork 134
Expand file tree
/
Copy pathrow.component.ts
More file actions
67 lines (51 loc) · 1.54 KB
/
row.component.ts
File metadata and controls
67 lines (51 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import {
Component, Input, Inject, forwardRef, Output, EventEmitter, OnDestroy
} from '@angular/core';
import { DataTable } from './table.component';
import { ROW_TEMPLATE } from './row.template';
import { ROW_STYLE } from "./row.style";
@Component({
selector: '[dataTableRow]',
template: ROW_TEMPLATE,
styles: [ROW_STYLE]
})
export class DataTableRow implements OnDestroy {
@Input() item: any;
@Input() index: number;
expanded: boolean;
// row selection:
private _selected: boolean;
@Output() selectedChange = new EventEmitter();
@Output() expandRowChange = new EventEmitter();
get selected() {
return this._selected;
}
set selected(selected) {
this._selected = selected;
this.selectedChange.emit(selected);
}
// other:
get displayIndex() {
if (this.dataTable.pagination) {
return this.dataTable.displayParams.offset + this.index + 1;
} else {
return this.index + 1;
}
}
getTooltip() {
if (this.dataTable.rowTooltip) {
return this.dataTable.rowTooltip(this.item, this, this.index);
}
return '';
}
expandRow(event: Event) {
event.stopPropagation();
this.expanded = !this.expanded;
this.expandRowChange.emit();
}
constructor(@Inject(forwardRef(() => DataTable)) public dataTable: DataTable) {}
ngOnDestroy() {
this.selected = false;
}
private _this = this; // FIXME is there no template keyword for this in angular 2?
}