-
Notifications
You must be signed in to change notification settings - Fork 776
/
matrix-row.component.ts
45 lines (44 loc) · 1.47 KB
/
matrix-row.component.ts
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
import { Component, ElementRef, Input, ViewChild } from "@angular/core";
import { BaseAngular } from "../base-angular";
import {
MatrixDropdownRowModelBase,
QuestionMatrixDropdownModelBase,
QuestionMatrixDropdownRenderedRow
} from "survey-core";
@Component({
selector: "sv-ng-matrix-row",
templateUrl: "./matrix-row.component.html",
styles: [":host { display: none; }"]
})
export class MatrixRowComponent extends BaseAngular<QuestionMatrixDropdownRenderedRow> {
@Input() model!: QuestionMatrixDropdownRenderedRow;
@Input() question!: QuestionMatrixDropdownModelBase;
@ViewChild("container", { static: false, read: ElementRef }) container!: ElementRef<HTMLTableRowElement>;
protected getModel(): QuestionMatrixDropdownRenderedRow {
return this.model;
}
public get row(): MatrixDropdownRowModelBase {
return this.model.row;
}
public trackCellBy(_: number, cell: any): string {
return cell.id;
}
protected override onModelChanged(): void {
super.onModelChanged();
if(this.previousModel) {
this.previousModel.setRootElement(undefined as any)
}
if(this.model && this.container?.nativeElement) {
this.model.setRootElement(this.container.nativeElement);
}
}
public ngAfterViewInit(): void {
if(this.model && this.container?.nativeElement) {
this.model.setRootElement(this.container.nativeElement)
}
}
public override ngOnDestroy(): void {
super.ngOnDestroy();
this.model.setRootElement(undefined as any);
}
}